Skip to content

Conversation

clydin
Copy link
Member

@clydin clydin commented Aug 19, 2025

The experimental Vitest-based unit test builder did not always correctly re-run tests in watch mode.

This commit refactors the Vitest executor to provide more accurate watch mode behavior by:

  • Disabling Vitest's internal file watcher (watch: null) to make the Angular builder's watcher the single source of truth.
  • Triggering a test run via vitest.rerunTestSpecifications() within the execute method after each incremental build is complete.

@clydin clydin added the target: major This PR is targeted for the next major release label Aug 19, 2025
@clydin clydin force-pushed the unit-test/watch-accuracy branch from 3f47f37 to 1672128 Compare August 19, 2025 21:34
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 19, 2025
@clydin clydin force-pushed the unit-test/watch-accuracy branch 3 times, most recently from bc782d3 to e4ba249 Compare August 20, 2025 18:27
clydin added 2 commits August 20, 2025 16:44
The experimental Vitest-based unit test builder did not always correctly re-run tests in watch mode.

This commit refactors the Vitest executor to provide more accurate watch mode behavior by:
- Disabling Vitest's internal file watcher (`watch: null`) to make the Angular builder's watcher the single source of truth.
- Triggering a test run via `vitest.rerunTestSpecifications()` within the `execute` method after each incremental build is complete.
The Vitest-based unit test builder created temporary output directories within `dist/test-out` for each run but did not remove them upon completion. This led to an accumulation of orphaned directories, consuming unnecessary disk space.

This commit introduces robust cleanup logic to the `VitestExecutor` by:
- Deleting the temporary output directory during graceful shutdown using the `asyncDispose` method.
- Registering a `SIGINT` process handler to ensure the directory is also removed during forceful interruptions, such as when a user presses `Ctrl-C` in watch mode.
@clydin clydin force-pushed the unit-test/watch-accuracy branch from e4ba249 to b9c49e3 Compare August 20, 2025 20:45
@clydin clydin requested a review from alan-agius4 August 21, 2025 12:50
@alan-agius4 alan-agius4 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 Aug 22, 2025
@clydin clydin merged commit b554bd7 into angular:main Aug 22, 2025
31 checks passed
@clydin clydin deleted the unit-test/watch-accuracy branch August 22, 2025 12:21
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: @angular/build target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants