Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wvankoppen opened this issue Nov 30, 2020 · 6 comments · Fixed by #243
Closed

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

wvankoppen opened this issue Nov 30, 2020 · 6 comments · Fixed by #243

Comments

@wvankoppen
Copy link

wvankoppen commented Nov 30, 2020

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 {}```
@satanTime
Copy link
Member

Hi @wvankoppen,

thanks for the report, a good catch, its fix will be release with the next version.

@satanTime
Copy link
Member

Hi @wvankoppen,

I hope this finds you well.

might you verify the fix? ng-mocks.zip

Thanks in advance!

satanTime referenced this issue in satanTime/ng-mocks Dec 1, 2020
satanTime referenced this issue in satanTime/ng-mocks Dec 1, 2020
@wvankoppen
Copy link
Author

Hi @satanTime,

Thanks for your quick reply!
I'm happy to see that the fix works like a charm!
Please let me know when the new release is coming :)

Regards Wouter

@satanTime
Copy link
Member

Hi @vespertilian,

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

@wvankoppen
Copy link
Author

Wonderful, thanks!

@satanTime
Copy link
Member

v11.2.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.

satanTime added a commit that referenced this issue Dec 15, 2020
chore(deps): update dependency ts-node to v9.1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants