Skip to content

Bug: "Nested" module replacement not working as expected #4486

@twjacobsen

Description

@twjacobsen

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 :(

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions