Epics can be unit-tested just like any other function in your application - they have a very specific set of inputs (the action$ stream) and the output is always an Observable. We can subscribe to this output Observable to assert that the actions going back into the Redux are the ones we expect.
export function fetchUserEpic(action$) { return action$.ofType('FETCH_USER') .map(action => ({ type: 'FETCH_USER_FULFILLED', payload: { name: 'Shane', user: action.payload } })) }
import {Observable} from 'rxjs'; import {ActionsObservable} from 'redux-observable'; import {fetchUserEpic} from "./fetch-user-epic"; it('should return correct actions', function () { const action$ = ActionsObservable.of({ type: 'FETCH_USER', payload: 'shakyshane' }); const output$ = fetchUserEpic(action$); output$.toArray().subscribe(actions => { expect(actions.length).toBe(1); }); });