Skip to content

Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise #844

Open
@DanielSchiavini

Description

@DanielSchiavini

Logs and screenshots
After installing the coverage plugin, the coverage is working great!
However, I constantly get this warning after each test:

[2855:0617/211145.460808:INFO:CONSOLE(68449)] "Cypress Warning: Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise.
The test title was:
  > "after each" hook
While this works in practice, it's often indicative of an anti-pattern. You almost never need to return both a promise and also invoke cy commands.
Cy commands themselves are already promise like, and you can likely avoid the use of the separate Promise.
https://on.cypress.io/returning-promise-and-commands-in-test", source: http://localhost:4000/__cypress/runner/cypress_runner.js (68449)
[2855:0617/211145.472633:INFO:CONSOLE(68449)] "Cypress Warning: Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise.
The test title was:
  > "after all" hook: collectBackendCoverage
While this works in practice, it's often indicative of an anti-pattern. You almost never need to return both a promise and also invoke cy commands.
Cy commands themselves are already promise like, and you can likely avoid the use of the separate Promise.
https://on.cypress.io/returning-promise-and-commands-in-test", source: http://localhost:4000/__cypress/runner/cypress_runner.js (68449)
[2855:0617/211145.484349:INFO:CONSOLE(68449)] "Cypress Warning: Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise.
The test title was:
  > "after all" hook: generateReport
While this works in practice, it's often indicative of an anti-pattern. You almost never need to return both a promise and also invoke cy commands.
Cy commands themselves are already promise like, and you can likely avoid the use of the separate Promise.
https://on.cypress.io/returning-promise-and-commands-in-test", source: http://localhost:4000/__cypress/runner/cypress_runner.js (68449)

This happens both in Github actions but also locally:
image

Versions

"@cypress/code-coverage": "^3.12.39"
"cypress": "13.11.0",
node: v20.14.0

Describe the bug
The after hooks should not mix cypress commands and promises

Link to the repo
Sorry, this is a closed repository. I suspect it's easy to reproduce.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions