You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browser Version: Chrome 62, Chromium 60, Electron 53
Is this a Feature or Bug?
Bug
Current behavior:
Successive cy.viewport() in different tests are "overwritten" by the last one
Desired behavior:
Setting viewport should work for a test, regardless of another viewport in another test.
How to reproduce:
Write several tests, each one with a different viewport setting.
Test code:
In the following coffeescript file, all tests are run with the wiewport set as 'iphone-5', 'landscape', i.e. the last one set.
# layout.coffeedescribe"Layout tests", ->presets= ['macbook-15', 'macbook-11', 'ipad-2', 'iphone-6+', 'iphone-5']
for preset in presets
for orientation in ['portrait', 'landscape']
it"Sign In button should work for #{preset} (#{orientation})", ->cy.viewport(preset, orientation)
cy.visit('/')
cy.get('body.with-layout-side-opened').should('not.exist')
cy.get('#menuButton').click()
cy.get("body.with-layout-side-opened")
cy.get("#signInModal").should('not.be.visible')
cy.get("#signInButton").click()
cy.get("#signInModal").should('be.visible')
I also tried cy.visit('/') before cy.viewport(preset, orientation), same issue.
Additional Info (images, stack traces, etc)
The text was updated successfully, but these errors were encountered:
I don't think this is an issue with Cypress, this is an issue with your loop.
Based on the way JavaScript works, it waits until the last moment to evaluate variables, it will only ever see the final loop iteration.
You need a closure here so that each function closes over the local scope of that variable.
If you wrote your loop (above) in plain JavaScript the result would also be the same.
# layout.coffeedescribe"Layout tests", ->presets= ['macbook-15', 'macbook-11', 'ipad-2', 'iphone-6+', 'iphone-5']
for preset in presets
for orientation in ['portrait', 'landscape']
## add IFFE here to create the closuredo (preset, orientation) ->it"Sign In button should work for #{preset} (#{orientation})", ->cy.viewport(preset, orientation)
cy.visit('/')
cy.get('body.with-layout-side-opened').should('not.exist')
cy.get('#menuButton').click()
cy.get("body.with-layout-side-opened")
cy.get("#signInModal").should('not.be.visible')
cy.get("#signInButton").click()
cy.get("#signInModal").should('be.visible')
Is this a Feature or Bug?
Bug
Current behavior:
Successive
cy.viewport()
in different tests are "overwritten" by the last oneDesired behavior:
Setting viewport should work for a test, regardless of another viewport in another test.
How to reproduce:
Write several tests, each one with a different viewport setting.
Test code:
In the following coffeescript file, all tests are run with the wiewport set as 'iphone-5', 'landscape', i.e. the last one set.
I also tried
cy.visit('/')
beforecy.viewport(preset, orientation)
, same issue.Additional Info (images, stack traces, etc)
The text was updated successfully, but these errors were encountered: