breaking: make cy.getAllCookies() a query command that retries until assertions pass#34270
Open
jennifer-shehane wants to merge 4 commits into
Open
breaking: make cy.getAllCookies() a query command that retries until assertions pass#34270jennifer-shehane wants to merge 4 commits into
jennifer-shehane wants to merge 4 commits into
Conversation
…assertions pass Follow-up to #34019, which converted cy.getCookie() and cy.getCookies() to query commands. cy.getAllCookies() now uses the same createCookieQuery() helper, so it re-reads cookies from the browser and retries attached assertions until they pass or the command times out. Since it reads cookies across all domains without touching the AUT's location, it opts out of the AUT communication check that getCookie(s) perform, preserving its previous behavior of working while the AUT is cross-origin. Its timeout now follows defaultCommandTimeout instead of responseTimeout, and overwriting it now requires Cypress.Commands.overwriteQuery(), consistent with the other cookie getter queries in 16.0.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012jMnEAaAWyUjSqgpd7qxo2
cypress
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Project |
cypress
|
| Branch Review |
claude/getallcookies-query-command-bo1d7v
|
| Run status |
|
| Run duration | 14m 32s |
| Commit |
|
| Committer | Jennifer Shehane |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
10
|
|
|
6
|
|
|
1021
|
|
|
6
|
|
|
19189
|
| View all changes introduced in this branch ↗︎ | |
Warning
Partial Report: The results for the Application Quality reports may be incomplete.
UI Coverage
64.47%
|
|
|---|---|
|
|
27
|
|
|
49
|
Accessibility
99.05%
|
|
|---|---|
|
|
0 critical
3 serious
2 moderate
0 minor
|
|
|
18
|
Tests for review

commands/traversals_shadow_dom.cy.js • 0 failed tests • 5x-driver-electron
| Test | Artifacts | |
|---|---|---|
The first 5 failed specs are shown, see all 730 specs in Cypress Cloud.

commands/waiting.cy.js • 1 flaky test • 5x-driver-chrome:beta
| Test | Artifacts | |
|---|---|---|
| ... > errors > throws when waiting for 2nd response to route |
Test Replay
|
|

commands/waiting.cy.js • 1 flaky test • 5x-driver-chrome
| Test | Artifacts | |
|---|---|---|
| ... > errors > throws when waiting for response to route |
Test Replay
|
|

choose-a-browser.cy.ts • 1 flaky test • launchpad-e2e
| Test | Artifacts | |
|---|---|---|
| Choose a browser page > System Browsers Detected > shows warning when launched with --browser path option that cannot be matched to found browsers |
Test Replay
Screenshots
|
|

e2e/origin/cookie_misc.cy.ts • 1 flaky test • 5x-driver-firefox
| Test | Artifacts | |||||||
|---|---|---|---|---|---|---|---|---|
| ... > works with Max-Age=0 |
| |||||||
| Test | Artifacts | |
|---|---|---|
| ... > throws when foo cannot resolve |
Test Replay
|
|
The first 5 flaky specs are shown, see all 6 specs in Cypress Cloud.
MartinLVila
reviewed
Jul 11, 2026
Pulls the identical options-defaulting, timeout derivation, and plural-cookie consoleProps log out of getCookies and getAllCookies into a small setupCookiesQuery helper that only varies by the log message. getCookie stays as-is since its consoleProps has a null/not-found branch and its own name-argument validation the plural commands don't share. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012jMnEAaAWyUjSqgpd7qxo2
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012jMnEAaAWyUjSqgpd7qxo2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cy.getCookie()andcy.getCookies()to query commands but leftcy.getAllCookies()as a regular command.Additional details
Why was this change necessary?
cy.getAllCookies()was still a regular command (Commands.addAll()) that executed once and returned its result, socy.getAllCookies().should('have.length', 2)would fail on the first read even when cookies were being set asynchronously — the same problem #34019 fixed forcy.getCookie()/cy.getCookies().What is affected by this change?
cy.getAllCookies()is now a query command (Commands.addQuery()) built on the sharedcreateCookieQuery()helper from breaking: make cy.getCookie(s) query commands that retry until assertions pass #34019. It re-reads cookies from the browser and retries any attached assertions until they pass or the command times out.defaultCommandTimeout(default4000) rather thanresponseTimeout(default30000), consistent with the other cookie getter queries.Cypress.Commands.overwriteQuery()instead ofCypress.Commands.overwrite().Timed out retrying after ...prefix.Implementation details
Unlike
getCookie/getCookies,getAllCookiesreads cookies across all domains and never reads the AUT's location, so it has never required communication with the AUT (it worked while the AUT was cross-origin, outsidecy.origin()). To preserve that,createCookieQuery()gains acheckAUTCommunicationoption (defaulttrue) thatgetAllCookiessets tofalse, skipping theCypress.ensure.commandCanCommunicateWithAUT()check the other two perform.The existing 16.0.0 changelog bullet from #34019 is extended to cover all three commands rather than adding a near-duplicate entry.
Steps to test
cy.getAllCookies().should('have.length', 1)retries until a cookie set asynchronously (e.g. after a login request resolves) is present.cy.getAllCookies({ timeout: 50 })timeout errors report asTimed out retrying after 50ms: ....defaultCommandTimeoutrather thanresponseTimeout.cy.getAllCookies()still works when the AUT is cross-origin (seecookies_spec_baseurl.cy.jssystem tests and the drivercy.origin()cookie specs).Driver spec:
yarn workspace @packages/driver cypress:run -- --spec cypress/e2e/commands/cookies.cy.jsHow has the user experience changed?
No visual change. Behavioral change:
cy.getAllCookies()chained assertions now retry instead of failing on the first read, and the default timeout is nowdefaultCommandTimeout— documented in the 16.0.0 Breaking Changes changelog section.PR Tasks
cypress-documentation?type definitions?🤖 Generated with Claude Code
https://claude.ai/code/session_012jMnEAaAWyUjSqgpd7qxo2
Generated by Claude Code
Note
Medium Risk
Breaking command semantics (timeout default, overwrite API, retry behavior) affect any suite using cy.getAllCookies(); scope is limited to the driver cookie commands.
Overview
cy.getAllCookies()is now a query command (likegetCookie/getCookies), so chained assertions re-read all cookies from the browser and retry until they pass or the command times out—fixing async cookie races (e.g.cy.getAllCookies().should('have.length', 1)after login).Implementation reuses
createCookieQuery()with a newsetupCookiesQuery()helper for shared logging/timeout defaults.getAllCookiespassescheckAUTCommunication: falseso it still works when the AUT is cross-origin (it never needed AUT location). Default timeout isdefaultCommandTimeout(notresponseTimeout); overwrites must useCypress.Commands.overwriteQuery(). Timeout errors use the standardTimed out retrying after …prefix.The 16.0.0 changelog breaking bullet now covers all three cookie getter commands.
Reviewed by Cursor Bugbot for commit ae988ad. Bugbot is set up for automated code reviews on this repo. Configure here.