cypress-io / cypress-io/code-coverage
Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise
- Dominant language
- TypeScript
- Stars
- 445
- Forks
- 115
- PR merge metrics
- No merged PRs in 30d
Description
**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:

**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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.