MockBuilder add import
See original GitHub issueHello again !
First of all, do you have a Gitter or a Discord to ask this kind of question and avoid creating issues every time ?
We are trying to use MockBuilder
, it looks great!
But, we are unable to import unmocked modules that are not part of the component module.
Here the original TestBed
:
TestBed.configureTestingModule({
declarations: [
MyComponent,
MockComponents(MatToolbar, MatIcon),
MockDirective(MatIcon)
],
imports: [
// StoreModule come from App top Module
StoreModule.forRoot(reducers, { runtimeChecks: environment.storeRuntimeChecks }),
StoreModule.forFeature(featureReducers.featureKey, featureReducers.reducer)
],
providers: [
{ provide: MyService, useValue: mockMyService },
],
})
Here the equivalent with MockBuilder
:
MockBuilder(MyComponent, ItsModule)
// I tried this but it doesn't work
.keep(StoreModule.forRoot(reducers, { runtimeChecks: environment.storeRuntimeChecks })) // Try also , { export: true }
.keep(StoreModule.forFeature(featureReducers.featureKey, featureReducers.reducer)) // Try also , { export: true }
.mock(MyService)
Can you help me on that ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
MockBuilder add import · Issue #197 · help-me-mom/ng-mocks
We are trying to use MockBuilder , it looks great! But, we are unable to import unmocked modules that are not part of...
Read more >MockBuilder - the simplest way to create mocks in Angular tests
MockBuilder - the simplest way to create mocks in Angular tests. ... Modules are added as imports to the MyModule .
Read more >ng-mocks/community - Gitter
Hi guys. I'm trying to test a route resolver and everything seems to be working fine for the successful resolve, but for unsuccessful...
Read more >ng-mocks - npm
An Angular testing library for creating mock services, components, directives, pipes and modules in unit tests.
Read more >ES6 Class Mocks - Jest
Jest can be used to mock ES6 classes that are imported into files you want to test.
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
Sorry for late response ! It’s work perfectly, thanks a lot !
Hi @kekel87,
might you verify that both of the issues are properly solved here: ng-mocks.zip?
now you can keep and mock modules with providers and pass anywhere abstract classes like DomSanitizer.