The mocha before hook will timeout after 4 seconds. This is not documented, to my understanding, anywhere, and is not default mocha behavior. It seems that Cypress is setting this timeout, but when it occurs, a generic CypressError exception is the only indication of the problem: CypressError: Cypress test was stopped while running this command.
I haven't been able to locate the timeout set in your source code after a brief scan, but our canary failure logs were consistently failing at 4 seconds before the fix included below.
The below diff in cypress/support/e2e.ts fixed the issue for us.
- before(async () => {
+ before(async function () {
+ // REMOVE WITH CAUTION: Setting a long timeout for this before logic so the hidden 4s timeout from + Cypress doesn't bite us.
+ this.timeout(20000);
Desired behavior
My request: determine whether this is expected behavior. If it is, improve the error log so the timeout is the clear root cause, and document this default timeout publicly. If it is not expected behavior, remove the 4 second timeout for the before hook (I'm not sure if this is applied to other hooks).
Test code to reproduce
The below diff in cypress/support/e2e.ts fixed the issue for us.
- before(async () => {
+ before(async function () {
+ // REMOVE WITH CAUTION: Setting a long timeout for this before logic so the hidden 4s timeout from + Cypress doesn't bite us.
+ this.timeout(20000);
Cypress Version
12.5.1
Node version
v18.20.4
Operating System
macOS 14.5 (repro'd on Amazon Linux 2 as well)
Debug Logs
CypressError: Cypress test was stopped while running this command
Current behavior
The mocha
before
hook will timeout after 4 seconds. This is not documented, to my understanding, anywhere, and is not default mocha behavior. It seems that Cypress is setting this timeout, but when it occurs, a generic CypressError exception is the only indication of the problem:CypressError: Cypress test was stopped while running this command
.I haven't been able to locate the timeout set in your source code after a brief scan, but our canary failure logs were consistently failing at 4 seconds before the fix included below.
The below diff in
cypress/support/e2e.ts
fixed the issue for us.Desired behavior
My request: determine whether this is expected behavior. If it is, improve the error log so the timeout is the clear root cause, and document this default timeout publicly. If it is not expected behavior, remove the 4 second timeout for the before hook (I'm not sure if this is applied to other hooks).
Test code to reproduce
The below diff in
cypress/support/e2e.ts
fixed the issue for us.Cypress Version
12.5.1
Node version
v18.20.4
Operating System
macOS 14.5 (repro'd on Amazon Linux 2 as well)
Debug Logs
Other
No response