@reibo/ngrx-mock-test
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

@reibo/ngrx-mock-test

npm GitHub npm

CircleCI

styled with prettier

A library that implements the features described on

Blog on medium

Use this library

full example on stackblitz or in the src folder

Install the npm dependency

npm i @reibo/ngrx-mock-test -d, or if you preffer yarn yarn add @reibo/ngrx-mock-test -d

Initialize the Mock store in your project

The purpose of this mock store is to use it on feature based stores.

You will provide the data in the store like you decide, so it is ideal to test with mocked data.

In the MockStoreModule in your Testbed imports with your feature name and an initial state.

beforeEach(async(() => {
 TestBed.configureTestingModule({
   imports: [ MockStoreModule.forRoot('feature_name', initialState)],
   ...
 }).compileComponents();
}));

Next get store out of the testbed

store = TestBed.get(Store);

Change the state in your test during testing with the mock

store.dispatch(new MockAction({ name: "foo" }));

Do you like to work with streams and you us marble testing?

Try out:

const inputStream = m.hot('-a-b-a', stream);
store.dispatch(new MockStream(inputStream));

Readme

Keywords

none

Package Sidebar

Install

npm i @reibo/ngrx-mock-test

Weekly Downloads

12

Version

0.0.8

License

none

Unpacked Size

98.8 kB

Total Files

32

Last publish

Collaborators

  • bo.vandersteene