diff --git a/packages/driver/src/cypress/cy.coffee b/packages/driver/src/cypress/cy.coffee index fe5c18c88e..48ee269332 100644 --- a/packages/driver/src/cypress/cy.coffee +++ b/packages/driver/src/cypress/cy.coffee @@ -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 diff --git a/packages/driver/src/cypress/runner.coffee b/packages/driver/src/cypress/runner.coffee index f37d9eae91..6767e682e6 100644 --- a/packages/driver/src/cypress/runner.coffee +++ b/packages/driver/src/cypress/runner.coffee @@ -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) diff --git a/packages/driver/test/cypress/integration/commands/angular_spec.coffee b/packages/driver/test/cypress/integration/commands/angular_spec.coffee index abdcb8a9e7..274671c0e7 100644 --- a/packages/driver/test/cypress/integration/commands/angular_spec.coffee +++ b/packages/driver/test/cypress/integration/commands/angular_spec.coffee @@ -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, => diff --git a/packages/driver/test/cypress/integration/commands/navigation_spec.coffee b/packages/driver/test/cypress/integration/commands/navigation_spec.coffee index 956d2be9a1..72e0d49976 100644 --- a/packages/driver/test/cypress/integration/commands/navigation_spec.coffee +++ b/packages/driver/test/cypress/integration/commands/navigation_spec.coffee @@ -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") diff --git a/packages/driver/test/cypress/integration/cypress/runner_spec.js b/packages/driver/test/cypress/integration/cypress/runner_spec.js index 54679af69d..e08df29ae8 100644 --- a/packages/driver/test/cypress/integration/cypress/runner_spec.js +++ b/packages/driver/test/cypress/integration/cypress/runner_spec.js @@ -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()) + }) +}) diff --git a/packages/server/__snapshots__/1_async_timeouts_spec.coffee.js b/packages/server/__snapshots__/1_async_timeouts_spec.coffee.js index 4b312c50ed..2517de4269 100644 --- a/packages/server/__snapshots__/1_async_timeouts_spec.coffee.js +++ b/packages/server/__snapshots__/1_async_timeouts_spec.coffee.js @@ -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 - - ` diff --git a/packages/server/test/e2e/1_async_timeouts_spec.coffee b/packages/server/test/e2e/1_async_timeouts_spec.coffee index c34e0e4f88..ba3c287596 100644 --- a/packages/server/test/e2e/1_async_timeouts_spec.coffee +++ b/packages/server/test/e2e/1_async_timeouts_spec.coffee @@ -7,5 +7,5 @@ describe "e2e async timeouts", -> e2e.exec(@, { spec: "async_timeouts_spec.coffee" snapshot: true - expectedExitCode: 1 + expectedExitCode: 2 }) diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/async_timeouts_spec.coffee b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/async_timeouts_spec.coffee index e54da4e144..fa70218a92 100644 --- a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/async_timeouts_spec.coffee +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/async_timeouts_spec.coffee @@ -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)