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

Add an error message for incorrect syntax when using wait() #17436

Closed
AbrahamBrookes opened this issue Jul 22, 2021 · 3 comments · Fixed by #17561
Closed

Add an error message for incorrect syntax when using wait() #17436

AbrahamBrookes opened this issue Jul 22, 2021 · 3 comments · Fixed by #17561

Comments

@AbrahamBrookes
Copy link

AbrahamBrookes commented Jul 22, 2021

What would you like?

I made a silly mistake today that stumped me for too long. When writing my intercept tests I passed the callback as a second parameter to wait, instead of using a then:

// WRONG:
cy.wait('@request', (interception) => {
    // do stuff
})

// RIGHT:
cy.wait('@request').then((interception) => {
    // do stuff
})

Obviously this was totally my mistake, but it seems like something that could have an error message for morons like me?

Why is this needed?

No response

Other

No response

@jennifer-shehane
Copy link
Member

This wouldn't be too hard to implement. Detect that the second argument passed to cy.wait() is a function and throw an error explaining that the 2nd argument is meant to be an options object. We do this in our other commands. We'd be open to a PR.

Code is here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/waiting.js#L269:L269

@jennifer-shehane jennifer-shehane added type: error message good first issue Good for newcomers stage: ready for work The issue is reproducible and in scope labels Jul 22, 2021
@corentinclichy
Copy link

Hi Jennifer,
Hope you are doing well.
Is it still needed a fixed?

I can try to solve this!

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Aug 2, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 4, 2021

Released in 8.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v8.2.0, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Aug 4, 2021
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants