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

it.skip before describe causing problems in both command line run and debugger #8086

Closed
mrchovo opened this issue Jul 24, 2020 · 4 comments · Fixed by #8113 · May be fixed by Omrisnyk/npm-lockfiles#145 or Omrisnyk/npm-lockfiles#164
Closed
Assignees
Labels
topic: hooks ↪ type: regression A bug that didn't appear until a specific Cy version release v4.10.0 🐛 Issue present since 4.10.0

Comments

@mrchovo
Copy link

mrchovo commented Jul 24, 2020

Current behavior:

I was using a structure in my test cases similar to this one:

describe("UPPER", () => {

    before(() => {})
    beforeEach(() => {})

    it("TEST1", () => {})
    it.skip("TEST2", () => {})

    describe("LOWER", () => {

        before(() => {})
        beforeEach(() => {})
        
        it("TEST3", () => {})
        it("TEST4", () => {})
    })
})

And I noticed that when I run this test suite in debugger it skipped all test cases in "LOWER". Also when I was running it in command line (chrome in headless mode) it cause an error "TypeError: Cannot read property 'addCommand' of undefined". It was because of skipping that one test case directly before describe (TEST2).

Screenshot from debugger:
image

Error output from running test in headless mode in chrome:

  1) UPPER
       "before all" hook for "TEST2":
     TypeError: Cannot read property 'addCommand' of undefined

Because this error occurred during a `before all` hook we are skipping the remaining tests in the current suite: `LOWER`
      at Test.addCommand (https://local.legito.com/__cypress/runner/cypress_runner.js:184075:12)
      at https://local.legito.com/__cypress/runner/cypress_runner.js:183574:27
      at RunnablesStore._withTest (https://local.legito.com/__cypress/runner/cypress_runner.js:183614:17)
      at RunnablesStore.addLog (https://local.legito.com/__cypress/runner/cypress_runner.js:183573:18)
      at EventEmitter.<anonymous> (https://local.legito.com/__cypress/runner/cypress_runner.js:181908:22)
      at executeAction (https://local.legito.com/__cypress/runner/cypress_runner.js:49202:13962)
      at EventEmitter.n (https://local.legito.com/__cypress/runner/cypress_runner.js:49202:13826)
      at EventEmitter.emit (https://local.legito.com/__cypress/runner/cypress_runner.js:51345:5)
      at $Cypress.<anonymous> (https://local.legito.com/__cypress/runner/cypress_runner.js:197914:19)
      at $Cypress.../driver/node_modules/eventemitter2/lib/eventemitter2.js.EventEmitter.emit (https://local.legito.com/__cypress/runner/cypress_runner.js:84133:19)
      at $Cypress.parent.<computed> [as emit] (https://local.legito.com/__cypress/runner/cypress_runner.js:170536:33)
      at $Cypress.action (https://local.legito.com/__cypress/runner/cypress_runner.js:164113:28)
      at trigger (https://local.legito.com/__cypress/runner/cypress_runner.js:171548:22)
      at triggerLog (https://local.legito.com/__cypress/runner/cypress_runner.js:171554:12)
      at $Cypress.logFn [as log] (https://local.legito.com/__cypress/runner/cypress_runner.js:171623:5)
      at logFn (https://local.legito.com/__cypress/runner/cypress_runner.js:163898:26)You can see from the output that the problem is in the before hook and when I tried to run test without before hook in describe("LOWER") it run correctly. I temporary resolved this problem by commenting the whole test case instead of using skip but that is not a proper way to do it.### Test code to reproduceI have tied it on this code just for test purposes and to not exposing original code:```jsdescribe("UPPER", () => {```before(() => {
cy.wait(1000);})beforeEach(() => {
cy.wait(1000);})```

it("TEST1", () => {
    cy.wait(1000);
})
it.skip("TEST2", () => {
    cy.wait(1000);
})


describe("LOWER", () => {


before(() => {
cy.wait(1000);
})
beforeEach(() => {
cy.wait(1000);
})

it("TEST3", () => {
cy.wait(1000);
})
it("TEST4", () => {
cy.wait(1000);
})


})

})


### Versions
Cypress: 4.11.0 and also tried on 4.10.0
OS: Windows 10 Pro
Browser: Chrome 84

Also failed by using cypress docker image: cypress/included:4.11.0 and cypress/included:4.10.0

@jennifer-shehane
Copy link
Member

I can reproduce this with the code below. cypress open doesn't bubble up any errors, nothing in the console. cypress run throws an exception.

This is a regression in 4.10.0. I tracked it down to being introduced in #7821 - the test runs and passes in the commit before this.

describe("UPPER", () => {
  it.skip("TEST1", () => {})

  describe("LOWER", () => {
    before(() => {
      cy.wait(1000);
    })

    it("TEST2", () => {})
  })
})

Screen Shot 2020-07-27 at 11 22 53 AM

  1) UPPER
       "before all" hook for "TEST1":
     TypeError: Cannot read property 'addCommand' of undefined

Because this error occurred during a `before all` hook we are skipping the remaining tests in the current suite: `LOWER`
      at Test.addCommand (http://localhost:64656/__cypress/runner/cypress_runner.js:184075:12)
      at http://localhost:64656/__cypress/runner/cypress_runner.js:183574:27
      at RunnablesStore._withTest (http://localhost:64656/__cypress/runner/cypress_runner.js:183614:17)
      at RunnablesStore.addLog (http://localhost:64656/__cypress/runner/cypress_runner.js:183573:18)
      at EventEmitter.<anonymous> (http://localhost:64656/__cypress/runner/cypress_runner.js:181908:22)
      at executeAction (http://localhost:64656/__cypress/runner/cypress_runner.js:49202:13962)
      at EventEmitter.n (http://localhost:64656/__cypress/runner/cypress_runner.js:49202:13826)
      at EventEmitter.emit (http://localhost:64656/__cypress/runner/cypress_runner.js:51345:5)
      at $Cypress.<anonymous> (http://localhost:64656/__cypress/runner/cypress_runner.js:197914:19)
      at $Cypress.../driver/node_modules/eventemitter2/lib/eventemitter2.js.EventEmitter.emit (http://localhost:64656/__cypress/runner/cypress_runner.js:84133:19)
      at $Cypress.parent.<computed> [as emit] (http://localhost:64656/__cypress/runner/cypress_runner.js:170536:33)
      at $Cypress.action (http://localhost:64656/__cypress/runner/cypress_runner.js:164113:28)
      at trigger (http://localhost:64656/__cypress/runner/cypress_runner.js:171548:22)
      at triggerLog (http://localhost:64656/__cypress/runner/cypress_runner.js:171554:12)
      at $Cypress.logFn [as log] (http://localhost:64656/__cypress/runner/cypress_runner.js:171623:5)
      at logFn (http://localhost:64656/__cypress/runner/cypress_runner.js:163898:26)

Workaround

Downgrade to Cypress 4.9.0.

@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Jul 27, 2020
@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jul 27, 2020
@jennifer-shehane jennifer-shehane added v4.10.0 🐛 Issue present since 4.10.0 internal-priority labels Jul 27, 2020
@panzarino panzarino self-assigned this Jul 28, 2020
@panzarino
Copy link
Contributor

It actually looks like this issue has (partially) been around for a while, where before hooks have not been getting properly attributed to the correct test when nested. 4.10.0 just implemented additional functionality that built off of these changes, which is why there is a full error now.

4.5.0 (farthest I went back):

Screen Shot 2020-07-28 at 7 01 41 PM

Ideally it should be showing the before hook here.

Full fix is coming soon anyways so the next released version should include the fix.

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope labels Jul 29, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 4, 2020

The code for this is done in cypress-io/cypress#8113, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Aug 4, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 5, 2020

Released in 4.12.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.12.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: hooks ↪ type: regression A bug that didn't appear until a specific Cy version release v4.10.0 🐛 Issue present since 4.10.0
Projects
None yet
3 participants