MockBuilder: Testing a Router Resolve Service declared in a lazy loading module
See original GitHub issueHi @satanTime,
When I use MockBuilder
to test a Router Resolve Service declared in a lazy loading module.
I get this error :
Error: Component XXXComponent is not part of any NgModule or the module has not been imported into your module
I’ve tried to use RouterTestingModule.withRoutes
, without success.
You can see the error in StackBlitz.
The code works fine in production.
angular.json Production : projects -> demo -> architect -> build -> options -> main -> src/main.ts Testing : projects -> demo -> architect -> build -> options -> main -> src/main-testing.ts
Thanks in advance. Best regards. Cyril
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to test declarations of lazy loaded modules in Angular
An example how to mock a lazy loaded module and test its declarations.
Read more >Unit testing lazy loaded modules routing - angular
Your app-routing.module.ts consists of only two things: the routes and the initialization of the RouterModule . You override both in your test ......
Read more >Lazy-loading feature modules - Angular
To lazy load Angular modules, use loadChildren (instead of component ) in your AppRoutingModule routes configuration as follows. AppRoutingModule (excerpt)
Read more >ng-mocks/community - Gitter
hi guys, been trying to use MockBuilder but I struggle on lazy-loaded modules as MockBuilder only accepts one Module as the second argument....
Read more >How To Use Lazy Loading Routes in Angular | DigitalOcean
Learn how to enable feature modules to be lazy-loaded in Angular, allowing to load the code for some routes to be loaded on-demand....
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
Based on the provided code MockBuilder should be used like that:
Thank you very much.