I'm trying to switch responses from the mocked out API during a test, so that I can test a caching option.
So basically what I want is that on the first request I get data1, and on the second request I get data2.
The problem is that on the second request, I am still getting data1, even thought I have told moxios to send back data2.
describe("getDataWithCache", () => {
it("should fetch data1 on first request and data2 on second request", () => {
moxios.stubRequest(testUrl, data1)
const response1 = await makeApiCall(testUrl)
expect(response1.data.name).toBe(data1.name)
// This is the line of code where the problem is occurring, because it isn't changing
// the mock data being returned
moxios.stubRequest(testUrl, data2)
const response2 = await makeApiCall(testUrl)
expect(response2.data.name).toBe(data2.name)
});
});