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 not clearing cookies between different spec files when running headlessly #2390

Closed
davidzambrana opened this issue Aug 23, 2018 · 2 comments
Labels
topic: cookies 🍪 type: duplicate This issue or pull request already exists

Comments

@davidzambrana
Copy link

Current behavior:

I have recently created a couple of tests for a new functionality we are working on, and realized that the cookies are not being cleared between my two spec files only when I run them headlessly.

So, my set up is of this kind

SpecFile1:

- before hook including cy.visit() and google OAuth login
- it('test case 1', () => {})

SpecFile2:

- beforeEach hook including cy.visit() and google OAuth login
- it('test case 1', () => {})
- it('test case 2', () => {})
- it('test case 3', () => {})

If I run this in interactive mode, everything passes; but when running from command line, I get an error in the beforeEach hook of the second spec file. The failure says that it cannot find the Login button, and that is because the user is already logged in (checked it in the video).

If I add a before hook in the second spec file including a cy.clearCookies() statement, it will work in both interactive and headless mode.

Desired behavior:

Cypress clears all cookies upon running a new spec file in both interactive and headless mode.

Steps to reproduce:

  • Two spec files performing a login in the beforeEach hook (I used OAuth against Google)
  • Do not clear cookies manually after the test in SpecFile1 or before the test in SpecFile2
  • Run headlessly

Versions

Cypress 3.1.0
Electron browser
Ubuntu Linux 16.04

@davidzambrana davidzambrana changed the title Cypress not clearing cookies between different spec files Cypress not clearing cookies between different spec files when running headlessly Aug 23, 2018
@davidzambrana
Copy link
Author

I think it is related (if not duplicating) this one #781

I hope at least that the info provided can help.

@jennifer-shehane
Copy link
Member

Duplicate of #781

@jennifer-shehane jennifer-shehane marked this as a duplicate of #781 Oct 20, 2018
@jennifer-shehane jennifer-shehane added the type: duplicate This issue or pull request already exists label Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cookies 🍪 type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants