ng-mocks: Bug: A module that is explicitly marked to be kept should be kept even if it's imported in another module that is mocked
Description of the bug
Let’s say that my component under test uses some other components that come from 3rd party library. These components are made available through a module that the 3rd party library also provides. Under the hood, the 3rd party library module is using ReactiveFormsModule.
Now, lets say that my component also does some forms stuff, so I need to use ReactiveFormsModule as well. Therefore I’d want to mock all the components that are coming from the 3rd party library, but keep ReactiveFormsModule.
I’d think that I should achieve this behavior via the following:
const deps = MockBuilder()
.mock(AwesomeLibraryModule) // the 3rd party library module
.keep(ReactiveFormsModule)
.build();
This however does not seem to work. The ReactiveFormsModule is not found in the deps.imports. Please see the repro link
A repo with an example of the bug
Link: https://codesandbox.io/s/nostalgic-moore-7sezz5?file=/src/test.spec.ts
Expected vs actual behavior
The ReactiveFormsModule should be included in the deps.imports.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (12 by maintainers)
Commits related to this issue
- feat(MockBuilder): default params as dependency or export #2647 [ ] throw if a dependency wasn't found [ ] update docs about form testing [ ] update migration docs about the breaking change BREAKING... — committed to satanTime/ng-mocks by satanTime 2 years ago
- feat(MockBuilder): default params as dependency or export #2647 - [ ] throw if a dependency wasn't found - [ ] update docs about form testing - [ ] update migration docs about the breaking change BR... — committed to satanTime/ng-mocks by satanTime 2 years ago
- feat(MockBuilder): default params as dependency or export #2647 - [ ] throw if a dependency wasn't found - [ ] update docs about form testing - [ ] update migration docs about the breaking change BR... — committed to satanTime/ng-mocks by satanTime 2 years ago
- feat(MockBuilder): default flags as dependency or export #2647 BREAKING CHANGE: MockBuilder with 2 params marks all chain calls as dependency BREAKING CHANGE: MockBuilder with 0-1 params marks all ch... — committed to satanTime/ng-mocks by satanTime 2 years ago
- feat(MockBuilder): default flags as dependency or export #2647 BREAKING CHANGE: MockBuilder with 2 params marks all chain calls as dependency BREAKING CHANGE: MockBuilder with 0-1 params marks all ch... — committed to satanTime/ng-mocks by satanTime 2 years ago
- feat(MockBuilder): default flags as dependency or export #2647 BREAKING CHANGE: MockBuilder with 2 params marks all chain calls as dependency BREAKING CHANGE: MockBuilder with 0-1 params marks all ch... — committed to satanTime/ng-mocks by satanTime 2 years ago
- feat(MockBuilder): default flags as dependency or export #2647 BREAKING CHANGE: MockBuilder with 2 params marks all chain calls as dependency BREAKING CHANGE: MockBuilder with 0-1 params marks all ch... — committed to satanTime/ng-mocks by satanTime 2 years ago
- feat(MockBuilder): default flags as dependency or export #2647 BREAKING CHANGE: MockBuilder with 2 params marks all chain calls as dependency BREAKING CHANGE: MockBuilder with 0-1 params marks all ch... — committed to satanTime/ng-mocks by satanTime 2 years ago
- feat(MockBuilder): default flags as dependency or export #2647 BREAKING CHANGE: MockBuilder with 2 params marks all chain calls as dependency BREAKING CHANGE: MockBuilder with 0-1 params marks all ch... — committed to satanTime/ng-mocks by satanTime 2 years ago
- Merge pull request #2741 from satanTime/issues/2647 feat(MockBuilder): default params as dependency or export #2647 — committed to help-me-mom/ng-mocks by satanTime 2 years ago
v14.0.0 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems.
I meant to provide a repo with the issue, so I could work on it on my side to find and fix the bug. So, basically, exactly what you did 😃
Thanks for the link. I’ll take a look next days where the problem is.