You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The combination of an async test with a command like cy.request() in addition to an afterEach or after hook with any Cypress command results in the following error:
Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
The command that returned the promise was:
> cy.request()
The cy command you invoked inside the promise was:
> cy.log()
Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.
Cypress will resolve your command with whatever the final Cypress command yields.
The reason this is an error instead of a warning is because Cypress internally queues commands serially whereas Promises execute as soon as they are invoked. Attempting to reconcile this would prevent Cypress from ever resolving.
Because this error occurred during a after each hook we are skipping the remaining tests in the current suite: async test + request repro
The test passes if the afterEach hook is removed. It also passes if the async is removed from the test. This case should not error at all or at least the error message should be improved to indicate the test should not be async. It took a while to realize the async was what was causing the error.
Desired behavior
Either tests run without erroring when they are async and there is an afterEach or at least the error message is improved to indicate that async tests are not supported.
Test code to reproduce
describe('async test + request repro',()=>{afterEach(()=>{cy.log('afterEach')})it('cy.request()',async()=>{cy.request('https://jsonplaceholder.cypress.io/todos/1')})})
Cypress Version
14.3.3
Node version
v20.18.1
Operating System
macOS 15.4.1
Debug Logs
Other
No response
The text was updated successfully, but these errors were encountered:
Current behavior
The combination of an async test with a command like
cy.request()
in addition to anafterEach
orafter
hook with any Cypress command results in the following error:The test passes if the
afterEach
hook is removed. It also passes if theasync
is removed from the test. This case should not error at all or at least the error message should be improved to indicate the test should not be async. It took a while to realize theasync
was what was causing the error.Desired behavior
Either tests run without erroring when they are
async
and there is anafterEach
or at least the error message is improved to indicate thatasync
tests are not supported.Test code to reproduce
Cypress Version
14.3.3
Node version
v20.18.1
Operating System
macOS 15.4.1
Debug Logs
Other
No response
The text was updated successfully, but these errors were encountered: