Skip to content
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

TestBed.overrideComponent doesn't update standalone components #48432

Open
satanTime opened this issue Dec 10, 2022 · 3 comments
Open

TestBed.overrideComponent doesn't update standalone components #48432

satanTime opened this issue Dec 10, 2022 · 3 comments
Assignees
Labels
area: testing Issues related to Angular testing features, such as TestBed bug cross-cutting: standalone Issues related to the NgModule-less world P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@satanTime
Copy link
Contributor

satanTime commented Dec 10, 2022

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

This removes imports - expected.

TestBed.overrideComponent(StandaloneComponent, {
  set: {
    imports: [],
  },
});

This doesn't change imports - unexpected.

TestBed.overrideComponent(StandaloneComponent, {
  set: {
    imports: [FakeTestingModule],
  },
});

There is stackblitz example - simply copy/paste the test.spec.ts to an angular v15 (v14 has his issue too) project.

Please provide a link to a minimal reproduction of the bug

https://github.com/satanTime/ng-mocks/blob/issues/4486/tests/issue-4486/angular.spec.ts

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 15.0.3
Node: 16.18.1
Package Manager: npm 8.19.3
OS: darwin x64

Angular: 15.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.3
@angular-devkit/build-angular   15.0.3
@angular-devkit/core            15.0.3
@angular-devkit/schematics      15.0.3
@schematics/angular             15.0.3
rxjs                            7.6.0
typescript                      4.8.4
webpack                         5.75.0

Anything else?

No response

@AndrewKushnir AndrewKushnir added area: testing Issues related to Angular testing features, such as TestBed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Dec 12, 2022
@ngbot ngbot bot modified the milestone: Backlog Dec 12, 2022
@AndrewKushnir AndrewKushnir self-assigned this Dec 12, 2022
@pkozlowski-opensource pkozlowski-opensource added bug cross-cutting: standalone Issues related to the NgModule-less world labels Dec 14, 2022
@lhenriquegomescamilo
Copy link

Does anyone have a workaround? 😢

timonmasberg added a commit to kordis-leitstelle/kordis that referenced this issue Jul 12, 2024
It is not possible to override standalone components. Thus, leaving us with the only possibility of mocking everything the dashboard component provides (which is quite a lot)
@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented Aug 30, 2024

@satanTime could you please check if the problem exists in the most recent version of Angular (18.2.2)? There was a fix for providers (58cf389), but it might resolve the issue described here as well. If the problem still exists, we'll perform further investigation. Thank you.

@JsantosDK
Copy link

Hello, @AndrewKushnir I can confirm that on version 18.2.5 this issue still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: testing Issues related to Angular testing features, such as TestBed bug cross-cutting: standalone Issues related to the NgModule-less world P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

5 participants