-
Notifications
You must be signed in to change notification settings - Fork 93
Override imports of routed standalone component #396
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
Comments
Hi, that's an interesting use case. |
Hi, I guess you are talking about the pre-standalone form of our test. It would be something like this: Component: @Component({
templateUrl: './main.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MainComponent {
readonly faClock = faClock;
readonly faHistory = faHistory;
readonly faFileDownload = faFileDownload;
} Test: const renderResult = await render(MainComponent, {
imports: [
FontAwesomeTestingModule,
FormsModule,
// more
],
declarations: [RangePickerStubComponent],
providers: [
{ provide: AlertService, useValue: alertService },
],
}); |
@Nosfistis Yea, I'm looking for a reproduction that can be used to investigate this. |
@Nosfistis I don't see a way to do this in a generic way that covers many cases. |
I think it would work fine, and it would be easy to adopt, since it looks a lot like the angular way currently we can make standalone component mocks: Testbed.configureTestingModule({
imports: [MyComponent],
})
.overrideComponent(MyComponent, {
add: { imports: [FontAwesomeTestingModule] },
remove: { imports: [FontAwesomeModule] }
}) |
I am having the case of a routed component that requires some resolved data. The component itself has some imports that require stubbing. In the pre-standalone era this was done easily via
imports
. With standalone it should be done viacomponentImports
. However,componentImports
does not override routed component imports, only the rendered component's imports.Now, I know that this is flawed, but I am trying to achieve a truly routed component whose imports are stubbed.
The text was updated successfully, but these errors were encountered: