Skip to content

feat(@schematics/angular): set up fake timers in beforeEach instead of beforeAll#33130

Merged
clydin merged 1 commit intoangular:mainfrom
yjaaidi:feat/set-up-fake-timers-in-before-each
May 5, 2026
Merged

feat(@schematics/angular): set up fake timers in beforeEach instead of beforeAll#33130
clydin merged 1 commit intoangular:mainfrom
yjaaidi:feat/set-up-fake-timers-in-before-each

Conversation

@yjaaidi
Copy link
Copy Markdown
Contributor

@yjaaidi yjaaidi commented May 5, 2026

When migrating fakeAsync to Vitest fake timers, fake timers were setup in beforeAll to support fakeAsync usage in beforeAll / afterAll hooks.
As brought up by @atscott, this was sacrificing timers isolation between tests.
This change resets fake timers between tests.
Any usage of fake timers APIs in beforeAll or afterAll hooks will fail.

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

…f beforeAll

When migrating `fakeAsync` to vitest fake timers, fake timers were setup in `beforeAll` to support `fakeAsync` usage in `beforeAll` / `afterAll` hooks.
This was sacrificing timers isolation between tests.
This change resets fake timers between tests.
Any usage of fake timers APIs in `beforeAll` or `afterAll` hooks will fail.
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: @schematics/angular labels May 5, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Jasmine-to-Vitest transformer to use "beforeEach" and "afterEach" hooks instead of "beforeAll" and "afterAll" when setting up and tearing down fake timers. This change ensures that fake timers are correctly initialized and reset for every individual test within a suite. I have no feedback to provide as there were no review comments to evaluate.

@clydin clydin added target: major This PR is targeted for the next major release action: merge The PR is ready for merge by the caretaker labels May 5, 2026
@clydin clydin merged commit c9f4081 into angular:main May 5, 2026
38 checks passed
@clydin
Copy link
Copy Markdown
Member

clydin commented May 5, 2026

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: @schematics/angular detected: feature PR contains a feature commit target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants