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.

Mocking modules with entry components

See original GitHub issue

I’m trying to mock a Module which contains an entry component (used for a MatDialog), but MockModule seems to erase in some way the original entryComponents definition. Is it intended behaviour?

@NgModule({
  declarations: [MyComponent],
  entryComponents: [MyComponent]
})
class TestModule {}

// From https://github.com/NetanelBasal/spectator
const spectator = createService({
    service: MyService,
    imports: [NoopAnimationsModule, MatDialogModule, MockModule(TestModule)]
  });

I get No component factory found for MyComponent. Did you add it to @NgModule.entryComponents?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ike18tcommented, May 14, 2019

Hey @IlCallo ,

I added entryComponents to mocked modules and it was released in https://github.com/ike18t/ng-mocks/releases/tag/v7.8.0

0reactions
satanTimecommented, Feb 20, 2020

Added fix to the same PR, it requires to avoid mock of the ‘InjectionToken HammerGestureConfig’ provider.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocking modules with entry components · Issue #51 - GitHub
I'm trying to mock a Module which contains an entry component (used for a MatDialog), but MockModule seems to erase in some way...
Read more >
Providing "entryComponents" for a TestBed - Stack Overflow
I'm trying to write a unit test and pass some TestComponent for it to create & render. TestBed . configureTestingModule(<any>{ declarations: [ ...
Read more >
Mock Imported React Components and ES Modules With Jest
Testing a React component can requires to control its imports, usually by mocking them. Several strategies are possible for this. Here is how...
Read more >
Mocking Components in Angular - Braydon Coyer
In Angular, a module is a mechanism to group components, directives, pipes and services that are related, in such a way that can...
Read more >
Jest Full and Partial Mock/Spy of CommonJS and ES6 Module ...
Spying/Stubbing calls to internal module functions with Jest ... Concept: “calling through” (as opposed to mocking). An internal/private/helper ...
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