Skip to content

fix(@angular/build): support extra test setup files with unit-test vitest runner #30664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clydin
Copy link
Member

@clydin clydin commented Jul 7, 2025

When using the experimental unit-test builder with Vitest, a new setupFiles option is now available. This option is similar to the Vitest option in that it allows for setup and configuration prior to each test. The setupFiles are executed after any application polyfills as well as after the TestBed initialization. If custom TestBed initialization is needed (this is not typical), The TestBed environment can first be reset in a setupFile and then initialized as needed. Note that resetting the TestBed environment in this way will cause the providersFile to no longer add any providers to the tests and any custom providers would need to be manually added during initialization.

@clydin clydin added the target: rc This PR is targeted for the next release-candidate label Jul 7, 2025
…test runner

When using the experimental unit-test builder with Vitest, a new `setupFiles`
option is now available. This option is similar to the Vitest option in
that it allows for setup and configuration prior to each test. The `setupFiles`
are executed after any application polyfills as well as after the TestBed
initialization. If custom TestBed initialization is needed (this is not typical),
The TestBed environment can first be reset in a setupFile and then initialized
as needed. Note that resetting the TestBed environment in this way will
cause the `providersFile` to no longer add any providers to the tests and
any custom providers would need to be manually added during initialization.
@clydin clydin force-pushed the unit-test/setup-files branch from 27e8f9e to 4ec2a33 Compare July 7, 2025 23:53
@clydin clydin requested a review from alan-agius4 July 8, 2025 13:12
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 8, 2025
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 area: @angular/build target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant