Test store
In order to test places (e.g. http or auth service) where store is accessed directly without action you need to create store.
describe('HttpService', () => {
beforeEach(() => {
NgStateTestBed.setTestEnvironment(new ImmerDataStrategy());
NgStateTestBed.createStore({test: 'test'});
});
it('should access store', (done) => {
Store.store.select(['test']).subscribe(state => {
expect(state).toEqual('test');
done();
});
});
});
createStore
adds store to dependency injection and also returns it as a value. So you can ue it in your tsts immediately.
Last updated
Was this helpful?