-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Thanks for your package. Love it !
But I seem to have an issue with it when using it along with async-await functions.
Test Code looks like
test("authenticate", async () => { let promiseObj = authenticate(email, password).then((msg) => {}).catch(catchFn) // simulating a server response let responseObj = { data: ["centralpet"] }; mockAxios.mockResponse(responseObj); expect(catchFn).not.toHaveBeenCalled(); return promiseObj; })
Now my source code - authenticate implementation looks like
authenticate = async (email, password) => { //This called a chrome async method. Not axios. let client = await utils.updateClientDetailsFromEmail(email); // This calls the axios methods. let status = await httpService.makeNetworkCall(requestObject); return status; }
Since inside the authenticate I am using await, the function gets paused before calling axios.
Meanwhile, the calling function continues execution and goes to mockResponse.
There mockAxios finds that no axios functions are in Queue so it throws No request to respond to! error.
If I await the authenticate call the mockResponse never gets executed so axios times out.
Can you check this issue or is there any workaround or config I am missing to avoid queuing of axios calls?