-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Currently, when standalone component/directive/pipe is present in the "declarations" field of the TestBed.configureTestingModule, the following error is thrown:
Error: Unexpected "MyStandaloneComponent" declaration in "DynamicTestModule" NgModule.
"MyStandaloneComponent" is marked as standalone and can't be declared in any NgModule - did
you intend to import it?
Which is good, but we can improve it further to mention TestBed.configureTestingModule specifically (since this is an API that developers interact with in this case) instead of DynamicTestModule:
Error: Unexpected `MyStandaloneComponent` found in the `declarations` array during the
`TestBed.configureTestingModule` call. The `MyStandaloneComponent` class is marked as
standalone and can't be declared in any NgModule - did you intend to import it instead (by
adding to the `imports` array)?
Implementation note: we should probably reuse the same function that produces the error, but allow providing some specific details (as a string) about the "origin" of the error (i.e. whether it's a generic error like we have now vs some specific call, e.g. TestBed.configureTestingModule). Basically we can use the proposed error message and in one case we can pass the "in "DynamicTestModule" NgModule" string and in another case - "during the TestBed.configureTestingModule call".