Skip to content

breaking: make cy.getAllCookies() a query command that retries until assertions pass#34270

Open
jennifer-shehane wants to merge 4 commits into
release/16.0.0from
claude/getallcookies-query-command-bo1d7v
Open

breaking: make cy.getAllCookies() a query command that retries until assertions pass#34270
jennifer-shehane wants to merge 4 commits into
release/16.0.0from
claude/getallcookies-query-command-bo1d7v

Conversation

@jennifer-shehane

@jennifer-shehane jennifer-shehane commented Jul 10, 2026

Copy link
Copy Markdown
Member

Additional details

Why was this change necessary?

cy.getAllCookies() was still a regular command (Commands.addAll()) that executed once and returned its result, so cy.getAllCookies().should('have.length', 2) would fail on the first read even when cookies were being set asynchronously — the same problem #34019 fixed for cy.getCookie() / cy.getCookies().

What is affected by this change?

  • cy.getAllCookies() is now a query command (Commands.addQuery()) built on the shared createCookieQuery() 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.
  • Its timeout now follows defaultCommandTimeout (default 4000) rather than responseTimeout (default 30000), consistent with the other cookie getter queries.
  • Overwriting it now requires Cypress.Commands.overwriteQuery() instead of Cypress.Commands.overwrite().
  • Timeout errors now report with the standard Timed out retrying after ... prefix.

Implementation details

Unlike getCookie/getCookies, getAllCookies reads 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, outside cy.origin()). To preserve that, createCookieQuery() gains a checkAUTCommunication option (default true) that getAllCookies sets to false, skipping the Cypress.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

  1. cy.getAllCookies().should('have.length', 1) retries until a cookie set asynchronously (e.g. after a login request resolves) is present.
  2. cy.getAllCookies({ timeout: 50 }) timeout errors report as Timed out retrying after 50ms: ....
  3. The command's default timeout follows defaultCommandTimeout rather than responseTimeout.
  4. cy.getAllCookies() still works when the AUT is cross-origin (see cookies_spec_baseurl.cy.js system tests and the driver cy.origin() cookie specs).

Driver spec: yarn workspace @packages/driver cypress:run -- --spec cypress/e2e/commands/cookies.cy.js

How 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 now defaultCommandTimeout — documented in the 16.0.0 Breaking Changes changelog section.

PR Tasks

  • Is there an associated issue with maintainer approval for PR submission?
  • Have tests been added/updated?
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the 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 (like getCookie / 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 new setupCookiesQuery() helper for shared logging/timeout defaults. getAllCookies passes checkAUTCommunication: false so it still works when the AUT is cross-origin (it never needed AUT location). Default timeout is defaultCommandTimeout (not responseTimeout); overwrites must use Cypress.Commands.overwriteQuery(). Timeout errors use the standard Timed 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.

…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
@jennifer-shehane jennifer-shehane self-assigned this Jul 10, 2026
@cypress

cypress Bot commented Jul 10, 2026

Copy link
Copy Markdown

cypress    Run #72356

Run Properties:  status check failed Failed #72356  •  git commit ae988adacd: Merge branch 'release/16.0.0' into claude/getallcookies-query-command-bo1d7v
Project cypress
Branch Review claude/getallcookies-query-command-bo1d7v
Run status status check failed Failed #72356
Run duration 14m 32s
Commit git commit ae988adacd: Merge branch 'release/16.0.0' into claude/getallcookies-query-command-bo1d7v
Committer Jennifer Shehane
View all properties for this run ↗︎

Test results
Tests that failed  Failures 10
Tests that were flaky  Flaky 6
Tests that did not run due to a developer annotating a test with .skip  Pending 1021
Tests that did not run due to a failure in a mocha hook  Skipped 6
Tests that passed  Passing 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%
  Untested elements 27  
  Tested elements 49  
Accessibility  99.05%
  Failed rules  0 critical   3 serious   2 moderate   0 minor
  Failed elements 18  

Tests for review

Failed  commands/actions/selectFile.cy.ts • 0 failed tests • 5x-driver-electron

View Output

Test Artifacts
Failed  e2e/origin/commands/log.cy.ts • 0 failed tests • 5x-driver-electron

View Output

Test Artifacts
Failed  e2e/origin/uncaught_errors.cy.ts • 0 failed tests • 5x-driver-electron

View Output

Test Artifacts
Failed  commands/actions/submit.cy.ts • 0 failed tests • 5x-driver-electron

View Output

Test Artifacts
Failed  commands/traversals_shadow_dom.cy.js • 0 failed tests • 5x-driver-electron

View Output

Test Artifacts

The first 5 failed specs are shown, see all 730 specs in Cypress Cloud.

Flakiness  commands/waiting.cy.js • 1 flaky test • 5x-driver-chrome:beta

View Output

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

View Output

Test Artifacts
... > errors > throws when waiting for response to route Test Replay
Flakiness  choose-a-browser.cy.ts • 1 flaky test • launchpad-e2e

View Output

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
Flakiness  e2e/origin/cookie_misc.cy.ts • 1 flaky test • 5x-driver-firefox

View Output

Test Artifacts
... > works with Max-Age=0
    </td>
  </tr></table>
Flakiness  e2e/origin/commands/waiting.cy.ts • 1 flaky test • 5x-driver-inject-document-domain-chrome

View Output

Test Artifacts
... > throws when foo cannot resolve Test Replay

The first 5 flaky specs are shown, see all 6 specs in Cypress Cloud.

@jennifer-shehane jennifer-shehane requested a review from a team July 10, 2026 16:46
@jennifer-shehane jennifer-shehane added the type: breaking change Requires a new major release version label Jul 10, 2026
Comment thread packages/driver/src/cy/commands/cookies.ts
claude and others added 3 commits July 13, 2026 19:12
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: breaking change Requires a new major release version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants