Skip to content
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

[Enhancement] Make next() call of testSaga implicit #148

Open
hedgerh opened this issue Sep 14, 2017 · 3 comments
Open

[Enhancement] Make next() call of testSaga implicit #148

hedgerh opened this issue Sep 14, 2017 · 3 comments

Comments

@hedgerh
Copy link

hedgerh commented Sep 14, 2017

Just came across this library, and I'm trying out testSaga. The first thing that stood out is the need to call .next() repeatedly after each effect. It'd be nice if that were optional, and you only needed to explicitly call .next() if you are passing a value back in:

    testSaga(sagas.fetchUser(api, { id: 123 }))
      .call(api.fetchUser, 123)
      .next(user)
      .put(actions.fetchUserOk(user))
      .put(actions.doAnotherAction())
      .put(actions.doSomethingElse())
      .isDone()

Would it be possible to implement this with the way testSaga is currently designed? Would you be open to this? I'd be willing to work on it if I could get a little direction, since I've just started digging in the codebase, and I'm not really familiar with it yet.

Edit: I just walked through the code, and think I understand how testSaga works now. It seems that methods like next return the effects api, and calling one of those returns the other api with next and other methods.

@hedgerh hedgerh changed the title Make next() call of testSaga implicit [Enhancement] Make next() call of testSaga implicit Sep 14, 2017
@hidalgofdz
Copy link

Have you tried the expectSaga? With expectSaga you just need to write the assertions for the effects that you are interested.

http://redux-saga-test-plan.jeremyfairbank.com/integration-testing/

@hedgerh
Copy link
Author

hedgerh commented Sep 14, 2017

@hidalgofdz: Hmm, I assumed it would involve more mocking and stuff to do integration type tests, but it doesn't seem too too bad. I will mess around and write some tests with both expectSaga and testSaga to see how they compare in terms of effort.

I did manage to implement the use of implicit nexts, and can put in a PR if its something that @jfairbank thinks wouldn't be a bad addition.

@jfairbank
Copy link
Owner

Hi @hedgerh!

Thanks for the idea. I like the spirit behind it, but I'm thinking it might be better to have a new method name instead of next (honestly, it would just end up being an alias to next). Maybe something like sendBack or sendValue to signal that we're sending data back to the saga. Personally, I have been finding more value out of expectSaga these days and haven't made many updates to testSaga. However, if others can find value out of this in testSaga, I'm open to checking a PR out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants