-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Cypress 4.10 breaks nested hooks - Cannot read property 'addCommand' of undefined #8214
Comments
What you are essentially doing with this require statement is the below, defining a Your I'm going to double check with the team on this one though. This error is likely being thrown from this line of code: https://github.com/cypress-io/cypress/blob/develop/packages/reporter/src/runnables/runnables-store.ts#L183:L183 which was changed in #7821 ReprobeforeEach(() => {
cy.log('foo')
beforeEach(() => {
cy.log('bar')
})
})
it('test', () => {}) 4.9.04.10.0 |
I tried this out in basic Mocha and this nesting of let num = 0
console.log(num) // logs 0
beforeEach(() => {
num += 1
console.log(num) // logs 1
beforeEach(() => {
num += 1
console.log(num) // logs 2
})
})
it('test', () => {
num += 1
console.log(num) // logs 3
}) |
I guess there's some disagreement with the team on whether this should be supported. Either way, I think this error should be handled in some way - or it should error if you nest hooks. So, we'll leave this open to evaluate more. |
Thx @jennifer-shehane. I reworked all of our code. This is no longer blocking me. I do think its a very fragile piece and may need more documentation and better error handling. |
The code for this is done in cypress-io/cypress#8400, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Steps:
Expected, as in Cypress 4.9 and previous versions it should log 2 messages.
Stack trace:
The text was updated successfully, but these errors were encountered: