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 commands after the promisify are failing #15

Open
mysticdevx opened this issue Nov 28, 2022 · 0 comments
Open

cypress commands after the promisify are failing #15

mysticdevx opened this issue Nov 28, 2022 · 0 comments

Comments

@mysticdevx
Copy link

Hi, whenever I try to use any cypress command after promisifying a command in a single it block, I am getting error as below.

Code:

  it('cy after promisify in single it block', async () => {
    const foo = await promisify(cy.wrap('foo')); // this is promisified
    cy.log('any cy code here'); // this does not run after the promisify
    expect(foo).to.equal('foo');
  });

Error i get:

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:

  > Test spec file cy after promisify in single it block

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.

More info:
promisify in separate it blocks works fine, i.e. promisify should be the last command in the it block. I have also tried with the cucumber framework. There also, if promisify is in separate step definitions, all is fine, but in the same step definition, again, I can not use any cy command after I use promisify, with the same error.

Cypress: v11.1.0
Node: v14.17.3

Any suggestion and resolution is appreciated

@mysticdevx mysticdevx changed the title multiple promisify commands fail in a single test cypress commands after the promisify are failing Nov 28, 2022
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