Description of the bug
When using MockBuilder to replace a module import with a "testing module", that in turn imports some other "testing module" is not working as expected. The declarations of the sub-testing-module is not made available in my tests
An example of the bug
Link: https://stackblitz.com/edit/github-fvnrfv?file=src/test.spec.ts
Expected vs actual behavior
Expected behaviour: The component in the test renders as name: sandboxt one testing two
Actual behaviour: The component in the test renders as name: sandboxt one two, indicating the nested module declarations are not used
Brief of the code structure:
Component imports Sub1Module which declares Component1 and imports Sub2Module. Sub2Module declares Component2.
In test, Sub1Module is replaced with Sub1TestingModule, which declares Component1 but imports Sub2TestingModule. Sub2TestingModule declares ComponentTesting2.
The selectors of Component2 and ComponentTesting2 are identical.
We've been using this pattern for regular non-standalone component testing, where we usually provide all module imports manually to the test. We've started using MockBuilder for standalone component testing, since it's very convenient - but this one issue is a pretty big deal to us :(
Description of the bug
When using
MockBuilderto replace a module import with a "testing module", that in turn imports some other "testing module" is not working as expected. The declarations of the sub-testing-module is not made available in my testsAn example of the bug
Link: https://stackblitz.com/edit/github-fvnrfv?file=src/test.spec.ts
Expected vs actual behavior
Expected behaviour: The component in the test renders as
name: sandboxt one testing twoActual behaviour: The component in the test renders as
name: sandboxt one two, indicating the nested module declarations are not usedBrief of the code structure:
Component imports
Sub1Modulewhich declaresComponent1and importsSub2Module.Sub2ModuledeclaresComponent2.In test,
Sub1Moduleis replaced withSub1TestingModule, which declaresComponent1but importsSub2TestingModule.Sub2TestingModuledeclaresComponentTesting2.The selectors of
Component2andComponentTesting2are identical.We've been using this pattern for regular non-standalone component testing, where we usually provide all module imports manually to the test. We've started using MockBuilder for standalone component testing, since it's very convenient - but this one issue is a pretty big deal to us :(