mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-11 17:50:01 -06:00
Fix async timeouts (#5097)
* fix async timeouts * add tests * add asyncTestTimeout config value * fix angular_spec, add timeout test * fix connectors_spec * fix querying_spec * fix e2e test e2e_config_fails * fix e2e specs, change calls to cy.timeout() * remove added config value, use `defaultCommandTimeout` * fix timing out internal tests * cleanup * add e2e test for async timeout after cy command * [review] remove most of runner_spec * add back runner_spec, whoops
This commit is contained in:
committed by
Jennifer Shehane
parent
c936f72c1b
commit
d8bdd4a85d
@@ -537,8 +537,8 @@ create = (specWindow, Cypress, Cookies, state, config, log) ->
|
||||
## cleanup could be called during a 'stop' event which
|
||||
## could happen in between a runnable because they are async
|
||||
if state("runnable")
|
||||
## make sure we don't ever time out this runnable now
|
||||
timeouts.clearTimeout()
|
||||
## make sure we reset the runnable's timeout now
|
||||
state("runnable").resetTimeout()
|
||||
|
||||
## if a command fails then after each commands
|
||||
## could also fail unless we clear this out
|
||||
|
||||
@@ -82,11 +82,13 @@ testBeforeRunAsync = (test, Cypress) ->
|
||||
fire("runner:test:before:run:async", test, Cypress)
|
||||
|
||||
runnableAfterRunAsync = (runnable, Cypress) ->
|
||||
runnable.clearTimeout()
|
||||
Promise.try ->
|
||||
if not fired("runner:runnable:after:run:async", runnable)
|
||||
fire("runner:runnable:after:run:async", runnable, Cypress)
|
||||
|
||||
testAfterRun = (test, Cypress) ->
|
||||
test.clearTimeout()
|
||||
if not fired(TEST_AFTER_RUN_EVENT, test)
|
||||
setWallClockDuration(test)
|
||||
fire(TEST_AFTER_RUN_EVENT, test, Cypress)
|
||||
|
||||
@@ -41,6 +41,7 @@ describe "src/cy/commands/angular", ->
|
||||
cy.ng("binding", "not-found")
|
||||
|
||||
it "cancels additional finds when aborted", (done) ->
|
||||
cy.timeout(1000)
|
||||
cy.stub(Cypress.runner, "stop")
|
||||
|
||||
retry = _.after 2, =>
|
||||
@@ -108,6 +109,7 @@ describe "src/cy/commands/angular", ->
|
||||
cy.ng("repeater", "not-found")
|
||||
|
||||
it "cancels additional finds when aborted", (done) ->
|
||||
cy.timeout(1000)
|
||||
cy.stub(Cypress.runner, "stop")
|
||||
|
||||
retry = _.after 2, =>
|
||||
@@ -221,6 +223,7 @@ describe "src/cy/commands/angular", ->
|
||||
done()
|
||||
|
||||
it "cancels additional finds when aborted", (done) ->
|
||||
cy.timeout(1000)
|
||||
cy.stub(Cypress.runner, "stop")
|
||||
|
||||
retry = _.after 2, =>
|
||||
|
||||
@@ -149,6 +149,7 @@ describe "src/cy/commands/navigation", ->
|
||||
expect(win.foo).to.be.undefined
|
||||
|
||||
it "throws when reload times out", (done) ->
|
||||
cy.timeout(1000)
|
||||
locReload = cy.spy(Cypress.utils, "locReload")
|
||||
|
||||
cy
|
||||
@@ -326,6 +327,7 @@ describe "src/cy/commands/navigation", ->
|
||||
cy.go(0)
|
||||
|
||||
it "throws when go times out", (done) ->
|
||||
cy.timeout(1000)
|
||||
cy
|
||||
.visit("/timeout?ms=100")
|
||||
.visit("/fixtures/jquery.html")
|
||||
|
||||
@@ -33,3 +33,11 @@ describe('src/cypress/runner', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('async timeouts', () => {
|
||||
it('does not timeout during cypress command', (done) => {
|
||||
cy.timeout(100)
|
||||
cy.wait(200)
|
||||
cy.then(() => done())
|
||||
})
|
||||
})
|
||||
|
||||
@@ -19,27 +19,32 @@ exports['e2e async timeouts failing1 1'] = `
|
||||
|
||||
async
|
||||
1) bar fails
|
||||
2) fails async after cypress command
|
||||
|
||||
|
||||
0 passing
|
||||
1 failing
|
||||
2 failing
|
||||
|
||||
1) async bar fails:
|
||||
Error: Timed out after '100ms'. The done() callback was never invoked!
|
||||
at stack trace line
|
||||
|
||||
2) async fails async after cypress command:
|
||||
Error: Timed out after '100ms'. The done() callback was never invoked!
|
||||
at stack trace line
|
||||
|
||||
|
||||
|
||||
|
||||
(Results)
|
||||
|
||||
┌──────────────────────────────────────────┐
|
||||
│ Tests: 1 │
|
||||
│ Tests: 2 │
|
||||
│ Passing: 0 │
|
||||
│ Failing: 1 │
|
||||
│ Failing: 2 │
|
||||
│ Pending: 0 │
|
||||
│ Skipped: 0 │
|
||||
│ Screenshots: 1 │
|
||||
│ Screenshots: 2 │
|
||||
│ Video: true │
|
||||
│ Duration: X seconds │
|
||||
│ Spec Ran: async_timeouts_spec.coffee │
|
||||
@@ -49,6 +54,7 @@ exports['e2e async timeouts failing1 1'] = `
|
||||
(Screenshots)
|
||||
|
||||
- /foo/bar/.projects/e2e/cypress/screenshots/async_timeouts_spec.coffee/async -- bar fails (failed).png (1280x720)
|
||||
- /foo/bar/.projects/e2e/cypress/screenshots/async_timeouts_spec.coffee/async -- fails async after cypress command (failed).png (1280x720)
|
||||
|
||||
|
||||
(Video)
|
||||
@@ -64,9 +70,9 @@ exports['e2e async timeouts failing1 1'] = `
|
||||
|
||||
Spec Tests Passing Failing Pending Skipped
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ ✖ async_timeouts_spec.coffee XX:XX 1 - 1 - - │
|
||||
│ ✖ async_timeouts_spec.coffee XX:XX 2 - 2 - - │
|
||||
└────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
1 of 1 failed (100%) XX:XX 1 - 1 - -
|
||||
1 of 1 failed (100%) XX:XX 2 - 2 - -
|
||||
|
||||
|
||||
`
|
||||
|
||||
@@ -7,5 +7,5 @@ describe "e2e async timeouts", ->
|
||||
e2e.exec(@, {
|
||||
spec: "async_timeouts_spec.coffee"
|
||||
snapshot: true
|
||||
expectedExitCode: 1
|
||||
expectedExitCode: 2
|
||||
})
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
describe "async", ->
|
||||
it.only "bar fails", (done) ->
|
||||
it "bar fails", (done) ->
|
||||
@timeout(100)
|
||||
|
||||
cy.on "fail", ->
|
||||
|
||||
## async caught fail
|
||||
foo.bar()
|
||||
|
||||
it "fails async after cypress command", (done) ->
|
||||
@timeout(100)
|
||||
|
||||
cy.wait(0)
|
||||
|
||||
Reference in New Issue
Block a user