Мне нужно протестировать асинхронную функцию (redux thunk)в jest. Для этого я использую fetchMock. Но у меня возникли проблемы. Тест заканчивается успешно, но я получаю ошибку от fetch
fetch-mock: No fallback response defined for POST to http:// *Link* /tmo/rest/user'
Тестовый блок в jest:
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);
});
console.log
FetchAuthLoading: false,
FetchAuthSuccess: false,
FetchAuthFailure: true,
AuthData: [],
AuthErros: fetch-mock: No fallback response defined for POST to http:// *Link* /tmo/rest/user'
Fetch-mock:
const body = {
login: login,
password: password,
deviceSerialNumber: '1111111',
currentAppVersion: AppVersion,
currentDateTime: time,
};
const header = {
Accept: 'application/json',
'Content-Type': 'application/json',
};