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

Annoying verbose Cypress browser console warning #7

Closed
Dan503 opened this issue Mar 15, 2020 · 1 comment
Closed

Annoying verbose Cypress browser console warning #7

Dan503 opened this issue Mar 15, 2020 · 1 comment

Comments

@Dan503
Copy link

Dan503 commented Mar 15, 2020

I get this really annoying warning in the browser console when I try to use async/await with promisify:

The warning

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:

element exists

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

Reduced test case

This is my reduced test case written in Typescript:

import promisify from 'cypress-promise'

const loadTestPage = (): Promise<Window> => promisify(cy.visit('./cypress/test-file.html'))

async function runTest() {
	it('element exists', async () => {
		await loadTestPage()
		cy.get(`#element`).should('exist')
	})
}

runTest()
@NicholasBoll
Copy link
Owner

Duplicate of #6

@NicholasBoll NicholasBoll marked this as a duplicate of #6 Mar 27, 2020
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

2 participants