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

Test runs infinitely with combination of async error, 'fail' event, and done callback #3349

Closed
chrisbreiding opened this issue Feb 6, 2019 · 5 comments · Fixed by #5097
Closed
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug
Milestone

Comments

@chrisbreiding
Copy link
Contributor

chrisbreiding commented Feb 6, 2019

Current behavior:

Test will hang if there's an async error, use of the fail event to catch the failing test, and a done callback. Since the command resolves before the error is thrown, the fail event is not fired and the done never gets invoked.

This is primarily an internal issue since we use the fail event to test Cypress. can be seen in the failing driver test in this PR. That test is using new and changed aspects of 4.0 5.0, but it can reproduced in the current version of Cypress using the steps below.

Desired behavior:

The fail event should be fired, which will allow the test to finish.

Steps to reproduce: (app code and test code)

// visit_error.html
<!DOCTYPE html>
<html>
  <script>
    setTimeout(() => {
      foo.bar()
    })
  </script>
</body>
</html>
// spec
it('tests visit error', (done) => {
  cy.on('fail', () => {
    done()
  })

  cy.visit('/visit_error.html')
})

Versions

Cypress 3.1.5
Chrome 71
MacOS 10.14.2

@chrisbreiding chrisbreiding added type: bug pkg/driver This is due to an issue in the packages/driver directory labels Feb 6, 2019
@chrisbreiding chrisbreiding added this to the Sprint 21 milestone Feb 6, 2019
@jennifer-shehane jennifer-shehane added the stage: ready for work The issue is reproducible and in scope label Feb 7, 2019
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Feb 7, 2019

Is there any reason this is slated for 4.0 5.0 if it is reproducible with current version? Would this create a breaking change?

@chrisbreiding
Copy link
Contributor Author

Good point. Changed it to 3.1.6.

@kuceb
Copy link
Contributor

kuceb commented Feb 8, 2019

@chrisbreiding I think there are two separate issues here:

  1. after any cypress command, the mocha timeout is cleared, so a test will never timeout. This test will hang forever:
it('should timeout', (done) => {
cy.visit('/')
}))
  1. cy.on('fail') is not getting called for some reason, unrelated

@chrisbreiding chrisbreiding self-assigned this Apr 4, 2019
@cypress-bot cypress-bot bot added stage: backlog and removed stage: ready for work The issue is reproducible and in scope labels Apr 4, 2019
@kuceb kuceb mentioned this issue Sep 6, 2019
6 tasks
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: backlog labels Sep 6, 2019
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: needs review The PR code is done & tested, needs review labels Sep 25, 2019
@jennifer-shehane
Copy link
Member

The code for this is done, but this has yet to be released. We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants