Lukket

Unit Test Async Action Creator for Failed Promise

I'm working on a test case where I'm trying to test async action creator for a failed response. But the error is a promise and when the unit test is running the error promise is not resolving and the test is failing.

eg:

// [login to view URL]

export const fetchData = () => {

return (dispatch) => {

return fetchJSON(URL).then((data) => {

dispatch(successAction(FETCH_SUCCESS, data));

}.catch((err) => {

[login to view URL]().then((value)) => {

dispatch(failedAction(FETCH_FAIL, err));

});

});

};

};

[login to view URL]

it("fetchData action", async() =>{

const fetchSpy = [login to view URL](jQuery, "get").reject({status: 400});

const dispatchSpy = [login to view URL]();

await fetchData()(dispatchSpy);

[login to view URL]();

[login to view URL](fetchSpy);

}

[login to view URL] is undefined as it is not resolving before the unit test case finishes.

Evner: Javascript, React.js

Se mere: redux testing mockstore, jest mock dispatch, redux-mock-store, react native mock store, redux mock store async actions, jest mock axios, redux thunk, redux test async actions, https error 890m com test php, android response json using async, recreate unit test visual studio, java unit test pdf creation creator, google gwt spring unit test, freelance photoshop action creator, bash script unit test harness

Om arbejdsgiveren:
( 6 bedømmelser ) Sunnyvale, United States

Projekt ID: #16898548