Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Test Redux Saga with an easy plan.
| Date | Stars |
|---|---|
| 2026-07-24 | 1244 |
| 2026-07-25 | 1244 |
| 2026-07-28 | 1244 |
| 2026-07-30 | 1244 |
| 2026-08-06 | 1244 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Redux Saga Test Plan
[](https://www.npmjs.com/package/redux-saga-test-plan)
[](https://travis-ci.org/jfairbank/redux-saga-test-plan)
[](https://codecov.io/gh/jfairbank/redux-saga-test-plan)
#### Test Redux Saga with an easy plan.
Redux Saga Test Plan makes testing sagas a breeze. Whether you need to test
exact effects and their ordering or just test your saga `put`'s a specific
action at some point, Redux Saga Test Plan has you covered.
Redux Saga Test Plan aims to embrace both integration testing and unit testing
approaches to make testing your sagas easy.
## Table of Contents
* [Integration Testing](#integration-testing)
* [Simple Example](#simple-example)
* [Mocking with Providers](#mocking-with-providers)
* [Example with Reducer](#example-with-reducer)
* [Unit Testing](#unit-testing)
* [Extending inspect options](#extending-inspect-options)
* [Install](#install)
## Documentation
* [Introduction](http://redux-saga-test-plan.jeremyfairbank.com/)
* [Getting Started](http://redux-saga-test-plan.jeremyfairbank.com/getting-started.html)
* [Integration Testing](http://redux-saga-test-plan.jeremyfairbank.com/integration-testing/)
* [Unit Testing](http://redux-saga-test-plan.jeremyfairbank.com/unit-testing/)
## Integration Testing
**Requires global `Promise` to be available**
One downside to unit testing sagas is that it couples your test to your
implementation. Simple reordering of yielded effects in your saga could break
your tests even if the functionality stays the same. If you're not concerned
with the order or exact effects your saga yields, then you can take an
integrative approach, testing the behavior of your saga when run by Redux Saga.
Then, you can simply test that a particular effect was yielded during the saga
run. For this, use the `expectSaga` test function.
### Simple Example
Import the `expectSaga` function and pass in your saga function as an argument.
Any additional arguments to `expectSaga` will become arguments to the saga
function. The return value is a chainable API with assertions for the different
effect creators available in Redux Saga.
In the example below, we test that the `userSaga` successfully `put`s a
`RECEIVE_USER` action with the `fakeUser` as the payload. We call `expectSaga`
with the `userSaga` and supply an `api` object as an argument to `userSaga`. We
assert the expected `put` effect via the `put` assertion method. Then, we call
the `dispatch` method with a `REQUEST_USER` action that contains the user id
payload. The `dispatch` method will supply actions to `take` effects. Finally,
we start the test by calling the `run` method which returns a `Promise`. Tests
with `expectSaga` will always run asynchronously, so the returned `Promise`
resolves when the saga finishes or when `expectSaga` forces a timeout. If you're
using a test runner like Jest, you can return the `Promise` inside your Jest
test so Jest knows when the test is complete.
```js
import { call, put, take } from 'redux-saga/effects';
import { expectSaga } from 'redux-saga-test-plan';
function* userSaga(api) {
const action = yield take('REQUEST_USER');
const user = yield call(api.fetchUser, action.payload);
yield put({ type: 'RECEIVE_USER', payload: user });
}
it('just works!', () => {
const api = {
fetchUser: id => ({ id, name: 'Tucker' }),
};
return expectSaga(userSaga, api)
// Assert that the `put` will eventually happen.
.put({
type: 'RECEIVE_USER',
payload: { id: 42, name: 'Tucker' },
})
// Dispatch any actions that the saga will `take`.
.dispatch({ type: 'REQUEST_USER', payload: 42 })
// Start the test. Returns a Promise.
.run();
});
```
### Mocking with ProvidExcerpt of 9,497 characters
Read on GitHub258
73
Greenkeeper · @greenkeeperio
18
13
4
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:f38c455b76a08397, topic:testing