ngrx / store

RxJS powered state management for Angular applications, inspired by Redux
MIT License
3.9k stars 311 forks source link

Component with NGRX Dependency Unit Test Issue in Karma #449

Closed lkyashu closed 7 years ago

lkyashu commented 7 years ago

While writing unit test for a component which depends on NGRX/Store for some value, i am getting an error saying value is undefined. However same is working fine when i am running the application. The angular app uses Webpack with AOT so don't know if that has something to do with it. I created a sample app and every thing seems to work fine in that. Unit test is successful. However in that Webpack with AOT application, it doesn't seem to work.

See the question on stackoverflow. I don't know whether i need to create a mock store or not, because simply adding the storemodule and adding the service in providers in spec.ts is not doing the needful. The same is working though in a sample app.

https://stackoverflow.com/questions/45253136/creating-a-mockstore-class-to-mock-ngrx-store-to-test-components-with-ngrx-store

jotatoledo commented 7 years ago

please use the issue tracker of @ngrx/platform