0

Maybe someone can help me write test? This theme is difficult for me, i'll hope somebody explain that.

  return axios.post("http://localhost:5000/login", {
    login,
    password,
  });
};
export const loginThunk = (login, password) => (dispatch) => {
  dispatch(fetchingAction(true));
  fakeLoginRequest(login, password)
    .then((response) => {
      dispatch(fetchingAction(false));
      if (response.data.isLoggedIn) {
        dispatch(loginAction(login, password, response.data.isLoggedIn));
      } else {
        alert("Wrong login or password");
      }
    })
    .catch((error) => {
      dispatch(fetchingAction(false));
      alert("cannot connect to server");
      console.log(error);
    });
};```
  • Please provide a [mvce](https://stackoverflow.com/help/minimal-reproducible-example) – Lin Du Mar 23 '22 at 05:40
  • Does this answer your question? [Testing dispatched actions in Redux thunk with Jest](https://stackoverflow.com/questions/48172819/testing-dispatched-actions-in-redux-thunk-with-jest) – timotgl Mar 23 '22 at 07:53

0 Answers0