Skip to content

beforeEach with done causes tests to hang indefinitely when done() called in promise.then() #4790

@viktomas

Description

@viktomas

Current behaviour:

When using the beforeEach with callback (i.e. beforeEach(done => promise.then(() => done())). The cypress runner hangs when a test fails.

Desired behavior:

When a test fails, move to the next one and in the end, turn off the runner.
At very least, implement timeout that won't allow runner to be running forever.

Steps to reproduce: (app code and test code)

Sorry I didn't know there is tiny version. Hopefully, tiny change to kitchensink should be ok
https://github.com/cypress-io/cypress-example-kitchensink/compare/master...viktomas:before-each-hangs?expand=1

This is the whole change in https://github.com/cypress-io/cypress-example-kitchensink that reproduces the issue.

diff --git a/cypress/integration/examples/actions.spec.js b/cypress/integration/examples/actions.spec.js
index 61c69fc..18c9f0f 100644
--- a/cypress/integration/examples/actions.spec.js
+++ b/cypress/integration/examples/actions.spec.js
@@ -1,8 +1,8 @@
 /// <reference types="Cypress" />

 context('Actions', () => {
-  beforeEach(() => {
-    cy.visit('http://localhost:8080/commands/actions')
+  beforeEach(done => {
+    cy.visit('http://localhost:8080/commands/actions').then(() => done())
   })

   // https://on.cypress.io/interacting-with-elements

Versions

Cypress 3.4.0, osx, node 8 and node 10

Note

Reading through #1075 I think these issues might be related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions