Skip to content

Promise issue on cy.logout #9

@dArignac

Description

@dArignac

Hi there,

first, thanks for the project, it helped me a lot!

Unfortunately I have an issue when using cy.logout.

I have tests with cy.login() in the Cypress before hook, those work great.
But I also want to test the logged out state, so I defined cy.logout() in the before hook accordingly. Those tests fail on the cy.logout() command with the following:

Error:    CypressError: Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.

The command that returned the promise was:

  > cy.logout()

The cy command you invoked inside the promise was:

  > cy.log()

Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.

Cypress will resolve your command with whatever the final Cypress command yields.

The reason this is an error instead of a warning is because Cypress internally queues commands serially whereas Promises execute as soon as they are invoked. Attempting to reconcile this would prevent Cypress from ever resolving.

https://on.cypress.io/returning-promise-and-commands-in-another-command

Because this error occurred during a 'before all' hook we are skipping the remaining tests in the current suite: 'Landing Page Unauthenticated'

I'm not sure if this is an issue on my side (wrong usage,...) or something of the lib.
For reference you can find the code of the failing test here.

Thanks for your help!
-Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions