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

Demonstrate Cypress warnings #8

Conversation

kpturner
Copy link

No description provided.

@kpturner kpturner changed the title Add globalBefore.ts Demonstrate Cypress warnings Feb 22, 2021
@kpturner
Copy link
Author

Run

npm run test:open

Run the only feature test available. Look at the browser console output to see numerous examples

DevTools failed to load SourceMap: Could not load content for http://localhost:56575/__cypress/runner/popper.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
cypress_runner.js:179344 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:

  > Passing with TypeScript "before 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.

@lgandecki
Copy link
Member

thanks for the reproduction. What if you don't use the cucumber preprocessor, but only pure cypress and try the same thing:

beforeEach(async () => {
    cy.log('beforeEach')
});

? I'm wondering whether this is related to our plugin at all

@kpturner
Copy link
Author

Well it does not appear to happen with this example https://github.com/TheBrainFamily/cypress-cucumber-example
so it is perhaps just related to the Typescript example and the baggage that goes with that.

@lgandecki
Copy link
Member

do we do beforeEach(async there?
The Async keyword is what's most probably causing the issue. I don't think it's related neither to typescript or our plugin. That's why I wanted you to verify without it :)

@kpturner
Copy link
Author

Ahh - sorry. I missed that subtlety. Yes that addition of "async" causes it in all the cypress-cucumber-preprocessor examples so I will try without the preprocessor and post back here.

@kpturner
Copy link
Author

Yep - it seems it happens in any project if you use the beforeEach hook and provide it with an async callback.
cypress-io/cypress#3139
Sorry to have bothered you.

@kpturner kpturner closed this Feb 23, 2021
@kpturner kpturner deleted the Demonstrate-cypress-console-warnings branch February 23, 2021 10:13
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

Successfully merging this pull request may close these issues.

None yet

2 participants