Skip to content

Fix flakey formatDate tests#67845

Open
dgp1130 wants to merge 2 commits intoangular:mainfrom
dgp1130:fix-format-date-flakes
Open

Fix flakey formatDate tests#67845
dgp1130 wants to merge 2 commits intoangular:mainfrom
dgp1130:fix-format-date-flakes

Conversation

@dgp1130
Copy link
Contributor

@dgp1130 dgp1130 commented Mar 25, 2026

Mostly generated by Gemini, fixing some flakey tests which were accidentally using device local time, which can vary for Bazel tests based on the location of RBE instances.

dgp1130 added 2 commits March 24, 2026 17:29
Removes the 'America/New_York' timezone string test case from `formatDate` tests because the underlying `Date.parse` API does not support IANA timezone strings. This caused the timezone calculation to silently fall back to the local executing machine's timezone, leading to non-deterministic test flakiness on Remote Build Execution (RBE) workers operating in varying geographic locations.
Replaced testing constructions of `Date` objects from `formatDate` tests from plain ISO strings over to 'new Date(year, month, date)'.

Instantiating 'new Date("2024-01-01")' parses the string strictly as UTC midnight ("2024-01-01T00:00:00.000Z"). When local operations execute (such as calculating `getThursdayThisIsoWeek` boundaries), the UTC date shifts relative to the executing machine's timezone. For example, in PST (GMT-8), that date translates exactly to 'December 31st 16:00:00', pushing week boundaries backwards.

By wrapping date constructs explicitly as 'new Date(2024, 0, 1)', it natively guarantees local midnight execution and prevents boundaries shifting on global CI Remote Build Execution (RBE) workers.

Example (from a machine in PST):

```javascript
> new Date('2024-01-01')
Sun Dec 31 2023 16:00:00 GMT-0800 (Pacific Standard Time)
> new Date(2024, 0, 1)
Mon Jan 01 2024 00:00:00 GMT-0800 (Pacific Standard Time)
```
@dgp1130 dgp1130 requested a review from thePunderWoman March 25, 2026 01:22
@dgp1130 dgp1130 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant