cypress-documentation icon indicating copy to clipboard operation
cypress-documentation copied to clipboard

[sessions] cy.session validate() return type not consistent with documentation

Open alvaromartmart opened this issue 4 years ago • 0 comments

I'm submitting a...

[x] Bug report
[ ] Content update
[ ] Process update (build, deployment, ... )

Type of bug / changes

The cy.session documentation says:

If the validate function return false, throws an exception, returns a Promise that resolves to false or rejects, or contains any failing Cypress command, the session will be considered invalid, and setup will be re-run.

However, the return type of the validate function is actually false | void, so it is not possible to return a Promise that resolves to false or rejects

cy.session( [user, pwd] => {
    /**/
}, {
    /* Typescript complains about this as the return type of validate is `false | void` */
    validate: () => Promise.reject('Invalid session)
}

I've assumed this is a documentation issue, but I might be wrong. I'd be up to submitting a PR if needed.

alvaromartmart avatar Sep 06 '21 07:09 alvaromartmart