Mocking NGRX store for easy testing your angular components

If you want to test your angular components and you are using redux with some selectors, then you’ll surely need


How to use it?

First, install as a development depenancy with npm i @reibo/ngrx-mock-test -d

Second, initialize the package and import it in your tests:

beforeEach(async(() => {
   imports: [ MockStoreModule.forRoot('freature_store_reducer', initialState)],

Final step, get the store and dispatch and action:

store = TestBed.get(Store);
store.dispatch(new MockAction({ name: "foo" }));

//if you test streams and use marble testing
const inputStream ='-a-b-a', stream);
store.dispatch(new MockStream(inputStream));

Example on stackblitz

Support and star that


Get The Best Of All Posts Delivered To Your Inbox

Subscribe to our newsletter and stay updated.