I am working on testing effects in ngrx store. And after updating ngrx to version I've found that the way, how to test it, has been changed.
import { hot, cold } from 'jasmine-marbles';
it('should work', () => {
actions = hot('--a-', { a: SomeAction });
const expected = cold('--b', { b: AnotherAction });
expect(effects.someSource$).toBeObservable(expected);
});
Unfortunately I didn't find any documentations for jasmine-marbles. Could anybody explain what mean the first parameter for hot an cold functions? And is it possible to find any documentation about it?
What is marble testing? Marble testing allows you to test asynchronous RxJS code synchronously and step-by-step with the help of RxJS TestScheduler test utility and using virtual time steps. There are also marble diagrams which demonstrate what is happening with a particular operation in the observable stream.
NgRx Effects are a popular part of NgRx, a state management library built for Angular. Effects are usually used to perform side effects like fetching data using HTTP, WebSockets, writing to browser storage, and more.
Finally found some documentation about it https://ngrx.io/guide/effects/testing#marble-diagrams
Probably it would be helpful to some one else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With