Open gothraven opened 4 years ago
I'm incredibly late on this, but in case anyone else sees this and needs the answer, you can test the effects with the following:
describe('testMe Saga', () => {
it('should do some work', () => {
expectSaga(testMe)
.provide([
[call(someApiFunction), 'good'],
])
.run()
.then((result) => {
const { effects } = result;
// Verify only one action was put
expect(effects.put).toHaveLength(1);
// Verify the action data is correct
expect(effects.put[0]).toEqual(
put(someAction(expectedPayload))
);
})
});
});
Brackets probably don't match up, but its the 'then' block that matters
Hi, i had the same problem. All I had to do is to insert a return
statement
describe('testMe Saga', () => {
it('should do some work', () => {
// 👇 This return is missing
return expectSaga(testMe)
....
});
});
@uwinkler Can you please explain how that helps ?
Any movement on this?
Introduction
I have been using
redux-saga-test-plan
for a while now, I wrote a bunch of tests using this library and it was a great help, I thank everyone who helped for that, but today we noticed some issue with our tests.Here is an example:
The problems
testMe
saga and make itput
another action at the end, the test will not break.testSaga
because we can't provide a return value forcall
Conclusion
Maybe i'm missing something, or I'm not using the library right, but i want to know how we can test and make sure that the saga doesn't do any other effect, in this kind of circumstances.