Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Timeout Recipe Does Not Stop Tests from Running When Maximum Time is Reached During beforeEach Block #550

Closed
todd-m-kemp opened this issue Aug 20, 2020 · 1 comment

Comments

@todd-m-kemp
Copy link

todd-m-kemp commented Aug 20, 2020

Issue:

The recipe for setting a global timeout that applies to every test using Cypress.on('test:before:run' ... does not work as expected when you hit the maximum time while a beforeEach is running.

Code to Reproduce:

describe('Wait 3 Seconds in beforeEach then Wait 7 Seconds In Test', function () {
  beforeEach(function () {
    cy.wait(3000)
  })

  it('Test 1', function () {
    cy.wait(7000)
  })
})

describe('Wait 7 Seconds in beforeEach then Wait 3 Seconds In Test', function () {
  beforeEach(function () {
    cy.wait(7000)
  })

  it('Test 2', function () {
    cy.wait(3000)
  })
})

I've used the recipe to set a timeout of 5 seconds. Both tests should fail with the error that it ran longer than 5 seconds, but the second test does not time out and eventually passes.

image

@todd-m-kemp
Copy link
Author

I've been revisiting this after a long period of time. 😂

After learning in this comment about cy.state('test'), I wondered if I replaced uses of cy.state('runnable') in the recipe with cy.state('test') that would resolve the issue I reported here. It seemed to fix things, but given that cy.state is undocumented I really don't know if making such a change is worrisome. I'd appreciate some insight on this @bahmutov; if doing so isn't a worry then maybe resolving this issue is as simple as updating the recipe accordingly?

@jennifer-shehane jennifer-shehane closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants