Skip to content

Fix flakey formatDate tests#67845

Merged
pkozlowski-opensource merged 2 commits intoangular:mainfrom
dgp1130:fix-format-date-flakes
Mar 26, 2026
Merged

Fix flakey formatDate tests#67845
pkozlowski-opensource merged 2 commits intoangular:mainfrom
dgp1130:fix-format-date-flakes

Conversation

@dgp1130
Copy link
Copy Markdown
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 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
dgp1130 added 2 commits March 25, 2026 09:44
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)
```
@alan-agius4 alan-agius4 force-pushed the fix-format-date-flakes branch from fc74b7a to 732f85c Compare March 25, 2026 09:44
@leonsenft leonsenft added the area: common Issues related to APIs in the @angular/common package label Mar 25, 2026
@ngbot ngbot bot added this to the Backlog milestone Mar 25, 2026
@dgp1130 dgp1130 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 26, 2026
@dgp1130 dgp1130 removed the request for review from thePunderWoman March 26, 2026 15:33
@pkozlowski-opensource pkozlowski-opensource merged commit 61ee183 into angular:main Mar 26, 2026
23 checks passed
@pkozlowski-opensource
Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: common Issues related to APIs in the @angular/common package target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants