Answer the question
In order to leave comments, you need to log in
No fallback response defined for POST. How to solve fetch-mock problem?
I need to test an async function (redux thunk) in jest. For this I use fetchMock. But I'm having problems. The test succeeds but I get an error from fetch
fetch-mock: No fallback response defined for POST to http:// *Link* /tmo/rest/user'
it('test: AuthMethod', async () => {
fetchMock.mock(Link, 200);
fetchMock.getOnce('/tmo/rest/user', {
body: JSON.stringify(body),
method: 'POST',
headers: header,
});
store.dispatch(AuthMethod()).then(() => {
let expectedActions = [
{
type: FETCH_AUTH_SUCCESS,
payload: data,
},
];
expect(store.getActions()).toEqual(expectedActions);
});
let value = store.getState();
console.log(value);
});
FetchAuthLoading: false,
FetchAuthSuccess: false,
FetchAuthFailure: true,
AuthData: [],
AuthErros: fetch-mock: No fallback response defined for POST to http:// *Link* /tmo/rest/user'
const body = {
login: login,
password: password,
deviceSerialNumber: '1111111',
currentAppVersion: AppVersion,
currentDateTime: time,
};
const header = {
Accept: 'application/json',
'Content-Type': 'application/json',
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question