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

how to check if another saga has been yielded #133

Open
mb-dmx opened this issue Jul 18, 2017 · 1 comment
Open

how to check if another saga has been yielded #133

mb-dmx opened this issue Jul 18, 2017 · 1 comment

Comments

@mb-dmx
Copy link

mb-dmx commented Jul 18, 2017

in redux-saga you can write:

function * mySubSaga() {
  yield 1;
}

function * mySaga() {
  yield mySubSaga();
}

seems, that it has same behavior as yield fork(mySubSaga);, but I'm not sure how to expect that mySubSaga has been yielded in the test plan.

Thanks.

@jfairbank
Copy link
Owner

Hi, @mb-dmx!

If you're using the testSaga function, there isn't a good way to test this, and not a pattern I would like to support. I would favor using fork as it is more explicit what mySaga is doing.

That being said, you can sorta test this with expectSaga, assuming mySubSaga yields an effect like put.

import { put } from 'redux-saga/effects';
import { expectSaga } from 'redux-saga-test-plan';

function* mySubSaga() {
  yield put({ type: 'DONE' });
}

function* mySaga() {
  yield mySubSaga();
}

it('runs mySubSaga', () => {
  return expectSaga(mySaga)
    .put({ type: 'DONE' })
    .run();
});

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

2 participants