samedi 23 janvier 2021

how to jest test an async action with axios in react ? - part 2

This is a continuation of my previous question.

I tried testing for REGISTER_FAIL case. This is what i did:

test("should not register a  user", async () => {
  axios.mockRejectedValue({
    status: 500,
  });
  const userInfo = {
    name: "",
    email: "",
    password: "",
  };
  await store.dispatch(register(userInfo)).then(() => {
    expect(store.getActions()[0]).toEqual({
      type: REGISTER_FAIL,
      payload: {
        token: null,
        isAuthenticated: false,
        loading: true,
        // user: null,
      },
    });
  });
});

I am getting this error: enter image description here

Aucun commentaire:

Enregistrer un commentaire