Reputation: 2169
When migrating my project from @ngrx 2.x to 4.1.0, I encountered the error message
NullInjectorError: No provider for Store!
The store was imported as shown in the docs:
import { StoreModule as NgRxStoreModule } from '@ngrx/store';
@NgModule({
imports: [
NgRxStoreModule.forRoot(reducerMap, {
initialState: initial
}),
StoreRouterConnectingModule,
EffectsModule.forRoot(effects)
],
providers: [AppActions]
})
export class StoreModule {}
Upvotes: 9
Views: 17720
Reputation: 5844
For ngrx 8 use:
import { provideMockStore } from '@ngrx/store/testing';
Upvotes: 0
Reputation: 754
I got this while I was trying to run tests in angular 7.
The solution for me was to:
describe
:let storeMock;
beforeEach
section: beforeEach(async () => {
storeMock = {
dispatch: jasmine.createSpy("dispatch"),
pipe: jasmine.createSpy("pipe").and.returnValue(from([{
...
requestTimeout: 5000,
...
}]))
};
TestBed.configureTestingModule
: TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
],
providers: [
...
{
provide: Store,
useValue: storeMock
}
...
]
});
```
Upvotes: 0
Reputation: 2169
Turned out that some of my services imported the store via
import { Store } from '@ngrx/store/src/store'
Changing the imports to
import { Store } from '@ngrx/store'
fixed the problem.
Upvotes: 11