Open arianacosta opened 5 years ago
@arianacosta Hey! I'm wondering the same thing, did you find a workaround afterall ?
@arianacosta
I found it, you have to pass the mocked data in the next()
method after your select()
.
So for you case, it should be something like that.
it('should dispatch multiple fetch panels', () => {
testSaga(reloadPanels)
.next()
.select()
.next(['panelA', 'panelB'])
.all([
put({
type: FETCH_PANEL,
payload: {
panel: 'panelA',
},
}),
put({
type: FETCH_PANEL,
payload: {
panel: 'panelB',
},
}),
])
.next()
.isDone();
});
Hello,
I've been trying to test that multiple PUT effects are being yielded by an ALL. The problem is that this saga uses
select
, but the default state for the application is empty. Therefore, mapping over an empty array produces no PUT effects.My questios are:
a) How can I set the initial state for each unit test? b) Is there a better or easier way of testing this?
Initial state that I'm trying to set before the test:
Saga:
Unit test: