Cannot read property 'ngModule' of undefined
See original GitHub issueI have the following setup: I like to test the ProfileOverviewComponent and create mocks for all declarables in its module, which is the ProfileOverviewLazyLoadedModule.
beforeEach(async(() => {
const metadata = ngMocks.guts(ProfileOverviewComponent, ProfileOverviewLazyLoadedModule);
metadata.providers.push({ provide: Store, useValue: storeMock });
TestBed.configureTestingModule(metadata).compileComponents();
}));
But now the test shows the following error: Failed: Cannot read property ‘ngModule’ of undefined

The ProfileOverviewLazyLoadedModule imports around 15 other modules, which have declarables on their own (that need to be mocked in this case). I think some module lookup t read the metadata of the module might be incorrect?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Cannot read property 'ngModule' of undefined - Stack Overflow
The error occurs when the value is undefined, so we can put here a conditional breakpoint with the condition !value , what will...
Read more >Cannot read property 'ngModule' of undefined · Issue #39573 ...
I believe it's not possible to error for circular deps; they aren't always a problem. It may be possible for the runtime JIT...
Read more >How to fix "Cannot read properties of undefined (reading ...
I don't have a good answer for this one... I want to iterate the app works perfectly, this is only a problem when...
Read more >NgModule - Angular
A name or path that uniquely identifies this NgModule in getNgModuleById . If left undefined , the NgModule is not registered with getNgModuleById...
Read more >ngmodel cannot read properties of undefined - You.com
Here's an example of a JavaScript TypeError: Cannot read property of undefined thrown when a property is attempted to be read on an...
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
@wvankoppen, thanks, glad to hear! I need to cover the fix with tests and will release it on the weekend.
v11.2.3 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.