question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ngMocks.guts() does not create mocks for declarables exported from other modules

See original GitHub issue

ngMocks.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:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
satanTimecommented, Dec 3, 2020

Hi @vespertilian,

thanks for the feedback. It will be released on Saturday / Sunday.

1reaction
satanTimecommented, Dec 1, 2020

Hi @wvankoppen,

I hope this finds you well.

might you verify the fix? ng-mocks.zip

Thanks in advance!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found