Skip to content

Commit 7d98cbe

Browse files
Merge branch 'release/1.0.4'
2 parents 00f0088 + ec3eab2 commit 7d98cbe

File tree

6 files changed

+1644
-1219
lines changed

6 files changed

+1644
-1219
lines changed

.babelrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"presets": ["es2015"]
2+
"presets": [
3+
["env", {
4+
"targets": {
5+
"browsers": ["last 2 versions"]
6+
}
7+
}]
8+
]
39
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ jspm_packages
3737
.node_repl_history
3838
.npmrc
3939
.yarnrc
40+
.vscode

.vscode/temp.sql

Whitespace-only changes.

README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ A no-brainer way of testing your Sagas™®
99
#### Examples include [Jest](https://facebook.github.io/jest/), [Mocha](https://mochajs.org/) and [AVA](https://github.com/avajs/ava)
1010

1111
[![npm](https://img.shields.io/npm/v/redux-saga-testing.svg?style=flat-square)](https://www.npmjs.com/package/redux-saga-testing)
12-
[![Dependency Status](https://david-dm.org/antoinejaussoin/redux-saga-testing.svg)](https://david-dm.org/antoinejaussoin/redux-saga-testing)
13-
[![devDependency Status](https://david-dm.org/antoinejaussoin/redux-saga-testing/dev-status.svg)](https://david-dm.org/antoinejaussoin/redux-saga-testing#info=devDependencies)
12+
[![Dependency Status](https://gemnasium.com/badges/github.com/antoinejaussoin/redux-saga-testing.svg)](https://gemnasium.com/github.com/antoinejaussoin/redux-saga-testing)
1413
[![Travis branch](https://img.shields.io/travis/antoinejaussoin/redux-saga-testing/master.svg?style=flat-square)](https://travis-ci.org/antoinejaussoin/redux-saga-testing)
15-
14+
[![Known Vulnerabilities](https://snyk.io/test/npm/redux-saga-testing/badge.svg)](https://snyk.io/test/npm/redux-saga-testing)
1615

1716
> Sagas are hard, testing them is even harder
1817
> (*Napoleon*)
@@ -247,6 +246,39 @@ describe('When testing a complex Saga', () => {
247246

248247
You have other examples in the [various](https://github.com/antoinejaussoin/redux-saga-testing/tree/master/jest) [tests](https://github.com/antoinejaussoin/redux-saga-testing/tree/master/mocha) [folders](https://github.com/antoinejaussoin/redux-saga-testing/tree/master/ava).
249248

249+
250+
## FAQ
251+
252+
- How can I test a Saga that uses `take` or `takeEvery`?
253+
254+
You should separate this generator in two: one that only uses `take` or `takeEvery` (the "watchers"), and the ones that atually run the code when the wait is over, like so:
255+
256+
```javascript
257+
import { takeEvery } from 'redux-saga';
258+
import { put } from 'redux-saga/effects';
259+
import { SOME_ACTION, ANOTHER_ACTION } from './state';
260+
261+
export function* onSomeAction(action) {
262+
const { payload: data } = action;
263+
yield put(actionGenerator(data));
264+
}
265+
266+
export function* onAnotherAction() {
267+
etc.
268+
}
269+
270+
export default function* rootSaga() {
271+
yield [
272+
takeEvery(SOME_ACTION, onSomeAction),
273+
takeEvery(ANOTHER_ACTION, onAnotherAction),
274+
etc.
275+
];
276+
}
277+
```
278+
279+
From the previous example, you don't have to test `rootSaga` but you can test `onSomeAction` and `onAnotherAction`.
280+
281+
250282
## Code coverage
251283

252284
This library should be compatible with your favourite code-coverage frameworks.
@@ -255,6 +287,16 @@ In the GitHub repo, you'll find examples using **Istanbul** (for Mocha) and **Je
255287

256288
## Change Log
257289

290+
### v1.0.4
291+
292+
- Updating dependencies
293+
- Fixed Ava issues with `babel-polyfill`
294+
295+
### v1.0.3
296+
297+
- Adding documentation regarding `take` and `takeEvery`
298+
- Updating dependencies
299+
258300
### v1.0.2
259301

260302
- Updating dependencies

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-saga-testing",
3-
"version": "1.0.2",
3+
"version": "1.0.4",
44
"description": "A no-brainer way of testing your Sagas",
55
"main": "main.js",
66
"scripts": {
@@ -36,19 +36,19 @@
3636
},
3737
"homepage": "https://github.com/antoinejaussoin/redux-saga-testing#readme",
3838
"devDependencies": {
39-
"ava": "0.17.0",
40-
"babel-core": "6.18.2",
41-
"babel-jest": "17.0.2",
42-
"babel-polyfill": "6.16.0",
43-
"babel-preset-es2015": "6.18.0",
44-
"babel-register": "6.18.0",
45-
"cross-env": "3.1.3",
39+
"ava": "^0.19.1",
40+
"babel-core": "^6.24.1",
41+
"babel-jest": "^20.0.3",
42+
"babel-polyfill": "^6.23.0",
43+
"babel-preset-env": "^1.5.1",
44+
"babel-register": "^6.24.1",
45+
"cross-env": "^5.0.0",
4646
"expect.js": "0.3.1",
4747
"istanbul": "1.1.0-alpha.1",
48-
"jest": "17.0.3",
49-
"mocha": "3.1.2",
50-
"redux-saga": "0.13.0",
51-
"sinon": "1.17.6"
48+
"jest": "^20.0.4",
49+
"mocha": "^3.4.2",
50+
"redux-saga": "^0.15.3",
51+
"sinon": "^2.3.2"
5252
},
5353
"jest": {
5454
"rootDir": "jest"
@@ -60,7 +60,8 @@
6060
"failFast": true,
6161
"verbose": true,
6262
"require": [
63-
"babel-register"
63+
"babel-register",
64+
"babel-polyfill"
6465
],
6566
"babel": "inherit"
6667
}

0 commit comments

Comments
 (0)