-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expectSaga test failure on missing assertions #99
Comments
Hi, @adamterlson! I like the spirit behind this idea, but requiring exact effects sounds like it couples the test to the implementation too much. If we required exact effects, then you'd also have to assert that the example saga yields If the desire is to require exact effects of a certain type, then we have a couple options. We could add a method like it('EXPLICITLY handles dispatching actions', () => {
return expectSaga(mainSaga, 40, 2)
.put.exactly([
{ type: 'DONE' },
{ type: 'ADD', payload: 42 },
])
.run();
}); Or we could potentially expose all yielded effects in the fulfilled value of the promise, as you and I discussed in #72. it('EXPLICITLY handles dispatching actions', async () => {
const effects = await expectSaga(mainSaga, 40, 2)
.put({ type: 'ADD', payload: 42 })
.put({ type: 'DONE' })
.run();
expect(effects.put.length).toBe(2);
}); What are your thoughts? |
You're right, I would indeed need to assert that the saga yields those takes if my As for implementation coupling, I assume you don't feel that way toward the My thought right now is: why not both? Having I would also want a way to get all effects, of all types, in the order they were yielded. That is, Thanks for the discussion! |
Feature request: it'd be wonderful to be able to assert that a given saga yields exactly the specified effects--no more, and (critically for this ticket) no less.
The following example demonstrates the issue:
So perhaps a new helper which ensures that all side effects have an assertion would be nice to help developers be sure that their saga is appropriately covered:
I'm just making up a crappy API that probably won't work. Welcome your thoughts!
The text was updated successfully, but these errors were encountered: