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

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 opened this issue Jun 18, 2024 · 0 comments

Comments

@DanielSchiavini
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant