question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cy.getCookie() does not support timeouts

See original GitHub issue

Current behavior:

Both of the following lines result in expected null to exist although the cookie becomes available within a timeframe of about 200ms:

cy.getCookie('token').should('exist')
cy.getCookie('token', { timeout: 5000 }).should('exist')

Adding a cy.wait(1000) above the lines will make them pass without error.

Desired behavior:

Steps to reproduce:

Use cy.getCookie('someCookie').should('exist') for a cookie which is saved with a little delay, e.g. session cookie after login.

Versions

cypress 3.4.0, electron 61, 5.2.1-arch1-1-ARCH

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:28
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
liambutlercommented, May 16, 2022

Recording of this issue in action: https://user-images.githubusercontent.com/24389501/168602990-48e7f37f-f25d-487b-859c-ef3bf07d9ae9.mp4

According to the docs for .should():

Assertions are automatically retried until they pass or time out.

However you can see from the video that this fails on the first assertion, and does not retry

Screenshot 2022-05-16 at 14 28 55
2reactions
miteshrathod09commented, Oct 25, 2019

Hi @jennifer-shehane,

I dont think 30 seconds timeout exists. Any particular version to look out for?

Also, passing a timeout param would be great!

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

getCookie
Because cy.getCookie() is asynchronous it is technically possible for there to be a timeout while talking to the internal Cypress automation APIs.
Read more >
How do I wait until a cookie is set?
Upon reception, the application sets the cookie. My problem is that I am not fond of the following call: cy.wait(1000). Without ...
Read more >
cypress-io/cypress - Gitter
I've checked the docs but can't find anything to speed this up. ... getCookies().then((cookies) => { cy.log(JSON.stringify(cookies)) }) });.
Read more >
Configurations in Cypress and How to Disable Default ...
Additionally, any DOM-based commands(such as cy.get(), etc.) will timeout. execTimeout, 60000, This configuration specifies the maximum time in ...
Read more >
cypress-wait-until: Docs, Tutorials, Reviews
Add this line to your project's cypress/support/commands.js : import 'cypress-wait-until'; ... cy.getCookie('token') // will not be retried .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found