Skip to content

fix(@angular/build): use virtual module for Karma TestBed initialization #30145

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

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

clydin
Copy link
Member

@clydin clydin commented Apr 22, 2025

Using a virtual module for the Karma-based unit testing setup allows for the Angular packages used within the TestBed initialization to resolve to the same dependencies used within the application and test code. This avoids the potential for multiple copies of @angular/core within the test output which can result in TestBed execution failure due to the module level variable usage within TestBed.

Using a virtual module for the Karma-based unit testing setup allows for
the Angular packages used within the TestBed initialization to resolve to
the same dependencies used within the application and test code. This avoids
the potential for multiple copies of `@angular/core` within the test output
which can result in TestBed execution failure due to the module level variable
usage within TestBed.
@clydin clydin added the target: patch This PR is targeted for the next patch release label Apr 22, 2025
@clydin clydin requested a review from alan-agius4 April 22, 2025 15:51
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Apr 22, 2025
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: review The PR is still awaiting reviews from at least one requested reviewer action: merge The PR is ready for merge by the caretaker labels Apr 23, 2025
@ngbot
Copy link

ngbot bot commented Apr 23, 2025

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "mergeability" is failing
If you want your PR to be merged, it has to pass all the CI checks.
If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Apr 23, 2025

Note: I tried this and this will not solve the tests when run with --preserve-symlinks=true, however I am going to merge this as it's a cleaner approach.

Actually I was wrong, it does fix the problem

@alan-agius4 alan-agius4 added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Apr 23, 2025
@alan-agius4 alan-agius4 merged commit 566de64 into angular:main Apr 23, 2025
36 of 37 checks passed
@clydin clydin deleted the karma/virtual-test-bed-init branch April 23, 2025 10:55
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: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants