Skip to content

Commit

Permalink
Fix testConfigOverrides not affecting viewport (#8006)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuceb authored Jul 17, 2020
1 parent aae5187 commit 0bf7785
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,25 @@ describe('per-test config', () => {
})
})

describe('viewport', () => {
// https://github.com/cypress-io/cypress/issues/7631
it('can set viewport in testConfigOverrides', { viewportWidth: 200, viewportHeight: 100 }, () => {
cy.visit('/fixtures/generic.html')
cy.window().then((win) => {
expect(win.innerWidth).eq(200)
expect(win.innerHeight).eq(100)
})
})

it('viewport does not leak between tests', () => {
cy.visit('/fixtures/generic.html')
cy.window().then((win) => {
expect(win.innerWidth).eq(1000)
expect(win.innerHeight).eq(660)
})
})
})

describe('testConfigOverrides baseUrl @slow', () => {
it('visit 1', { baseUrl: 'http://localhost:3501' }, () => {
cy.visit('/fixtures/generic.html')
Expand Down
8 changes: 5 additions & 3 deletions packages/driver/src/cy/commands/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const validOrientations = ['landscape', 'portrait']
// refresh would cause viewport to hang
let currentViewport = null

module.exports = (Commands, Cypress, cy, state, config) => {
const defaultViewport = _.pick(config(), 'viewportWidth', 'viewportHeight')
module.exports = (Commands, Cypress, cy, state) => {
const defaultViewport = _.pick(Cypress.config(), 'viewportWidth', 'viewportHeight')

// currentViewport could already be set due to previous runs
currentViewport = currentViewport || defaultViewport
Expand All @@ -41,7 +41,9 @@ module.exports = (Commands, Cypress, cy, state, config) => {
// need to restore prior to running the next test
// after which we simply null and wait for the
// next viewport change
setViewportAndSynchronize(defaultViewport.viewportWidth, defaultViewport.viewportHeight)
const configDefaultViewport = _.pick(Cypress.config(), 'viewportWidth', 'viewportHeight')

setViewportAndSynchronize(configDefaultViewport.viewportWidth, configDefaultViewport.viewportHeight)
})

const setViewportAndSynchronize = (width, height) => {
Expand Down

3 comments on commit 0bf7785

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 0bf7785 Jul 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.1/linux-x64/circle-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-397862/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.1/circle-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-397851/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 0bf7785 Jul 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.1/win32-ia32/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.1/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.10.1/win32-ia32/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.1/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.1/win32-ia32/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.1/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.1/win32-ia32/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.10.1/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 0bf7785 Jul 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.1/win32-x64/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.1/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.10.1/win32-x64/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.1/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.1/win32-x64/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.1/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.1/win32-x64/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.10.1/appveyor-develop-0bf7785d75f32614ac0a8debb5e4d87e2e9a3ecb-34148619/cypress.tgz

Please sign in to comment.