I use jest for my tests. I use reaction and reduction, and I have this action:
function getData(id, notify) {
return (dispatch, ...) => {
dispatch(anotherFunction());
Promise.all(['resource1', 'resource2', 'resource3'])
.then(([response1,response2,response3]) => {
... handle responses
})
.catch(error => { dispatch(handleError(error)); }
};
}
I searched in the jest documentation how to install a test for this action, but I could not find a way. I tried something like this:
it('test description', (done) => {
const expectedActions = [{type: {...}, payload: {...}},{type: {...}, payload: {...}},...];
fetchMock.get('resource1', ...);
fetchMock.get('resource2', ...);
fetchMock.get('resource3', ...);
... then the rest of the test calls
});
Unsuccessfully. So how should I proceed?
source
share