Platform: No provider for MockStore

Created on 2 Apr 2020  路  2Comments  路  Source: ngrx/platform

Other information:

I am trying to setup testing using the store for one of my components and it seems that the provideMockStore function is not actually providing the MockStore. I have to also include MockStore in my providers.

I am unsure if this is expected (as the docs do not show this) or if I am implementing testing incorrectly.

The error I am getting is this:

Failed: R3InjectorError(CompilerModule)[MockStore -> MockStore]: 
NullInjectorError: No provider for MockStore!

However, if I add MockStore to the providers array, it works fine.

...
    TestBed.configureTestingModule({
      declarations: [
        LoginPage
      ],
      providers: [
        MockStore,
        provideMockStore()
      ]
    });
...

I would be willing to submit a PR for the docs :heart:

[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

Most helpful comment

Hi, what version of NgRx are you using?
This should be fixed in NgRx v9.

All 2 comments

Hi, what version of NgRx are you using?
This should be fixed in NgRx v9.

You're right, thank you. Closing!

Was this page helpful?
0 / 5 - 0 ratings