ngMocks.guts() does not create mocks for declarables exported from other modules
See original GitHub issuengMocks.guts() does not create mocks for declarables exported from other modules.
This happens when a module is imported that exports a declarable (a component, directive or pipe) that it does not declare in itself.
This leads to the following error: Error: Can’t export pipe MockOfTranslatePipe from MockOfMyTranslateModule as it was neither declared nor imported!
Reproduction steps:
@NgModule({
declarations : [
AppComponent
],
imports : [
BrowserModule,
MyTranslateModule // <- This module exports TranslatePipe but does not declare it!
],
providers : [],
bootstrap : [AppComponent]
})
export class AppModule {
}
@NgModule({
imports: [TranslateModule],
declarations: [], // <- TranslatePipe is NOT declared because it is imported from TranslateModule
exports: [TranslatePipe],
})
export class MyTranslateModule {}```
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
ngMocks.guts() does not create mocks for declarables ...
guts() does not create mocks for declarables exported from other modules. This happens when a module is imported that exports a declarable (a ......
Read more >How to update to the latest version of ng-mocks
Now it does not export all mock imports and mock declarations, but respects exports of modules. The story is the same as in...
Read more >Mocking a module function which is exported and called ...
Side question 1: Should I be focusing on testing the logic of the function itself rather the other called functions?
Read more >ng-mocks/community - Gitter
Component's wrapping module declares schemas: [CUSTOM_ELEMENTS_SCHEMA] in its metadata to avoid rendering error like 'my-ng-content-slot-name' is not a ...
Read more >Module Mocking in Jest - codeburst
utils.js'jest.mock('./utils.js')describe('named exports - automatically mocked file with no return values', () => {
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @vespertilian,
thanks for the feedback. It will be released on Saturday / Sunday.
Hi @wvankoppen,
I hope this finds you well.
might you verify the fix? ng-mocks.zip
Thanks in advance!