You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-4Lines changed: 36 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,7 @@ This examples is now actually using the `redux-saga` utility functions.
102
102
103
103
The important point to note here, is that Sagas **describe** what happens, and don't actually act on it.
104
104
For example, an API will never be called, you don't have to mock it, when using `call`.
105
+
Same thing for a selector, you don't need to mock the state when using `yield select(mySelector)`.
105
106
106
107
This makes testing very easy indeed.
107
108
@@ -146,25 +147,29 @@ describe('When testing a very simple Saga', () => {
146
147
147
148
## Testing a complex Saga
148
149
149
-
This example deals with pretty much all use-cases for using Sagas, which involves calling an API, getting exceptions, and have some conditional logic based on some inputs.
150
+
This example deals with pretty much all use-cases for using Sagas, which involves using a `select`or, `call`ing an API, getting exceptions, have some conditional logic based on some inputs and `put`ing new actions.
@@ -249,7 +272,7 @@ You have other examples in the [various](https://github.com/antoinejaussoin/redu
249
272
250
273
## FAQ
251
274
252
-
- How can I test a Saga that uses `take` or `takeEvery`?
275
+
####How can I test a Saga that uses `take` or `takeEvery`?
253
276
254
277
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:
From the previous example, you don't have to test `rootSaga` but you can test `onSomeAction` and `onAnotherAction`.
280
303
304
+
#### Do I need to mock the store and/or the state?
305
+
306
+
No you don't. If you read the examples above carefuly, you'll notice that the actual selector (for example) is never called. That means you don't need to mock anything, just return the value your selector should have returned.
307
+
This library is to test a saga *workflow*, not about testing your actual *selectors*. If you need to test a selector, do it in isolation (it's just a pure function after all).
308
+
281
309
282
310
## Code coverage
283
311
@@ -287,6 +315,10 @@ In the GitHub repo, you'll find examples using **Istanbul** (for Mocha) and **Je
287
315
288
316
## Change Log
289
317
318
+
### v1.0.5
319
+
- Updating dependencies
320
+
- Adding examples using `selector`s (thanks [@TAGC](https://github.com/tagc) for the suggestion)
0 commit comments