Skip to content

Conversation

clydin
Copy link
Member

@clydin clydin commented Sep 4, 2025

The Vitest unit-test runner is updated to use a fully in-memory provider for test files and build artifacts. Previously, the runner would write bundled test files to a temporary directory on disk. This exposed intermediate build artifacts to the user in test output and incurred an unnecessary performance penalty from disk I/O.

With this change, a custom Vite plugin now serves all test-related files (including test entry points, code chunks, and polyfills) directly from the in-memory build results. This provides two key benefits:

  1. Improved Developer Experience: Vitest now operates on the original TypeScript source file paths. This ensures that test output, error messages, and stack traces correctly reference the files authored by the developer, simplifying debugging.
  2. Increased Performance: By eliminating all disk writes and the need for a temporary output directory, the test setup is faster and more efficient, especially in watch mode.

Closes #30822
Closes #30823

The Vitest unit-test runner is updated to use a fully in-memory provider for test files and build artifacts. Previously, the runner would write bundled test files to a temporary directory on disk. This exposed intermediate build artifacts to the user in test output and incurred an unnecessary performance penalty from disk I/O.

With this change, a custom Vite plugin now serves all test-related files (including test entry points, code chunks, and polyfills) directly from the in-memory build results. This provides two key benefits:

1.  **Improved Developer Experience**: Vitest now operates on the original TypeScript source file paths. This ensures that test output, error messages, and stack traces correctly reference the files authored by the developer, simplifying debugging.
2.  **Increased Performance**: By eliminating all disk writes and the need for a temporary output directory, the test setup is faster and more efficient, especially in watch mode.
The unit test suite for the `exclude` option in the Vitest runner was previously disabled. This change re-enables the test suite to confirm that the `exclude` option is functioning correctly and preventing specified test files from being executed.
@clydin clydin added the target: major This PR is targeted for the next major release label Sep 4, 2025
@clydin clydin marked this pull request as ready for review September 4, 2025 01:16
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 4, 2025
@clydin clydin 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 Sep 4, 2025
@clydin clydin merged commit 269ef26 into angular:main Sep 4, 2025
36 checks passed
@clydin clydin deleted the unit-test/virtual-vitest-files branch September 4, 2025 02:10
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.

[Vitest]: Incorrect stacktrace in reporter [Vitest]: Incorrect filepaths for test files in reporters
2 participants