# redux-saga-test

> My finest module

Latest version **1.0.1** (published 2017-01-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-saga-test
pnpm add redux-saga-test
yarn add redux-saga-test
bun add redux-saga-test
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-01-16 |
| First published | 2016-04-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Stoeffel |
| Maintainers | aaronjensen, schtoeffel |
| Keywords | redux, redux-saga, saga, testing |

## Links

- npm: https://www.npmjs.com/package/redux-saga-test
- Repository: https://github.com/stoeffel/redux-saga-test
- Homepage: https://github.com/stoeffel/redux-saga-test#readme
- Issues: https://github.com/stoeffel/redux-saga-test/issues
- npm.io page: https://npm.io/package/redux-saga-test

## Dependencies (1)

- [lodash.curry](https://npm.io/package/lodash.curry.md) ^4.0.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-01-16
- 1.0.0 — 2016-11-25
- 0.1.0 — 2016-08-24
- 0.0.3 — 2016-05-24
- 0.0.2 — 2016-04-24
- 0.0.1 — 2016-04-24

## README

# redux-saga-test [![Build Status](https://travis-ci.org/stoeffel/redux-saga-test.svg?branch=master)](https://travis-ci.org/stoeffel/redux-saga-test)

> A little helper to test [redux-saga][rs].


## Install

```
$ npm install --save-dev redux-saga-test
```


## Usage

The saga under test.
```js
function * testSaga () {
  try {
    yield put({type: 'FETCHING'})
    const data = yield call(loadData)
    yield put({type: 'FETCHED', payload: data})
  } catch (e) {
    yield put({type: 'FETCHED', payload: e})
  }
```

The test looks like this:

```js
const fromGenerator = require('redux-saga-test');

test('saga', (t) => {
  const expect = fromGenerator(t, testSaga()) // <= pass your assert library with a `deepEqual` method.

  expect.next().put({type: 'FETCHING'})
  expect.next().call(loadData)
  expect.next(mockData).put({type: 'FETCHED', payload: mockData})
  expect.next().returns()
})
```

To test a `watcher` you can use `expect.takeEvery/takeLatest`.

The watcher:
```js
function * watchEvery () {
  yield * takeEvery('TEST_ACTION', testSaga)
}
```

The test:
```js
test('takeEvery', (t) => {
  const expect = fromGenerator(t, watchEvery())
  expect.takeEvery('TEST_ACTION', testSaga)
})
```



For more examples look at the [tests](./test.js)


## License

MIT © [Stoeffel](http://stoeffel.github.io)

---
_Source: https://npm.io/package/redux-saga-test · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
