getsaf / shallow-render

Angular testing made easy with shallow rendering and easy mocking. https://getsaf.github.io/shallow-render
MIT License
273 stars 25 forks source link

Shallow testing for standalone components? #237

Closed floisloading closed 1 year ago

floisloading commented 1 year ago

Is this possible? I couldn't find any documentation. Using any parameter for Module in new Shallow(ColorComponent, SharedModule); results in an error:

Error: Unexpected "ColorComponent" found in the "declarations" array of the "ShallowTestModule" NgModule, "ColorComponent" 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)?
        at verifySemanticsOfNgModuleDef (node_modules/@angular/core/fesm2020/core.mjs:24319:15)
        at forEach (node_modules/@angular/core/fesm2020/core.mjs:24292:9)
        at Array.forEach (<anonymous>)
        at verifySemanticsOfNgModuleDef (node_modules/@angular/core/fesm2020/core.mjs:24290:60)
        at Function.get (node_modules/@angular/core/fesm2020/core.mjs:24243:21)
        at TestBedCompiler.applyProviderOverridesInScope (node_modules/@angular/core/fesm2020/testing.mjs:25520:33)
        at TestBedCompiler.compileTestModule (node_modules/@angular/core/fesm2020/testing.mjs:25810:14)
        at TestBedCompiler.finalize (node_modules/@angular/core/fesm2020/testing.mjs:25362:14)

I'm using shallow-render 14.2.0 and Angular 14.2.1

freddysilber commented 1 year ago

I'm running into the same issue running Angular 14.2.10. In my case, I have a Pipe that's marked as standalone breaking my tests.