I've got a saga that has some error handling logic in it - I want to test that a call is made three times and provide a response for each invocation. The use case is that the saga retries on the first two errors before giving up, so I need a sequence of response: [fail, fail, success]
it("must succeed after the first two requests are failures", () =>
expectSaga(
sagaToTest
).provide([
[
call(getdata, request),
throwError(new Error("oops")) // do this twice and succeed on the third invication
]
])
.call(getdata, request)
.call(getdata, request)
.call(getdata, request)
.put(actions.itSucceeded("message"))
.run());
});
This is straightforward in other testing / mocking libraries but for some reason I can't seem to find the right documentation.
Thanks!