I created a component using the Angular CLI (quite recent version)
ng --version
19.2.14
I did this using ng g c foo
The problem I have with this is that the FooComponent is standalone (it should be) but the test file is not. When I run ng test I get the following error:
Unexpected "FooComponent" found in the "declarations" array of the "TestBed.configureTestingModule" call, "FooComponent" is marked as standalone and can't be declared in any NgModule - did you intend to import it instead (by adding it to the "imports" array)?
In order to fix this, I have to move FooComponent from here
TestBed.configureTestingModule({
declarations: [FooComponent],
imports: [IonicModule.forRoot()]
}).compileComponents();
to here
TestBed.configureTestingModule({
imports: [IonicModule.forRoot(), FooComponent]
}).compileComponents();
Every time I generate component, service, guard, ...
Why does it do that? Why the inconsistency? Is there a fix?
standaloneinto account, but perhaps it'sundefined(which now defaults totrue) and takesdeclarationsinstead ofimports. Swapping the conditional would solve it