1th call to fetch should have had a URL of ... but was undefined
ErlanBazarov opened this issue · comments
erlan commented
Here is my code:
await new Promise(resolve => setTimeout(resolve, 1000));
console.log("CALLS", fetchMock.mock.calls, fetchMock.mock.calls[1][1].method);
expect(fetchMock).toHaveFetchedTimes(3);
expect(fetchMock).toHaveNthPosted(
1,
`${API_HOST}/workouts`,
);
The last assertion is giving me the error "1th call to fetch should have had a URL of http://localhost:1111/workouts but was undefined":
The output from console.log:
CALLS [
[
'http://localhost:1111/workouts',
{ credentials: 'same-origin', headers: [Object], method: 'GET' }
],
[
'http://localhost:1111/workouts/',
{
credentials: 'same-origin',
headers: [Object],
method: 'POST',
body: '{"id":1,"secondId":1}'
}
],
[
'http://localhost:1111/workouts/1',
{
credentials: 'same-origin',
headers: [Object],
method: 'PATCH',
body: '{"name":"sample name"}'
}
]
] POST