CypressError: Timed out retrying: Expected to find element with selector when date‑picker fails due to locale mismatch
0 reputation · 03 Jul 2024, 00:34 UTC
CypressError: Timed out retrying: Expected to find element with selector
When a date‑picker component fails to render due to locale mismatch, Cypress throws the timeout error above. The failure is triggered by the application’s date formatting not matching the test environment’s locale.
Current Time‑zone Support
Cypress runs tests in the host machine’s local time zone. There is no per‑test time‑zone configuration, and cy.clock() only freezes the current timestamp, not the zone offset. Tests that depend on offsets must manually adjust the date string or use a library such as Luxon.
Unresolved Feature Request
An open GitHub issue proposes a Cypress.config('timezone', 'America/New_York') API to set a per‑test time zone, but the proposal remains unmerged.
1. Will Cypress add per‑test time‑zone support in a future release? 2. How can cy.clock() be combined with a date library to achieve consistent rendering across time zones? 3. What strategy should be adopted for writing date‑picker tests that must run reliably on CI machines with different system zones?