1.3.28 • Published 7 years ago

redux-observable-test-helpers v1.3.28

Weekly downloads
15
License
ISC
Repository
github
Last release
7 years ago

redux-observable-test-helpers

Unit test helpers for redux-observable epics

Install

Install with npm:

npm i redux-observable-test-helpers --save-dev

Background

Testing async code that creates side effects isn't easy. One recommendation to make async testing with RXJS easier and more consistent is incorporating "marble notation" as a DSL for creating unit tests. "Marble Tests" are tests that use a specialized VirtualScheduler called the TestScheduler. They enable us to test asynchronous operations in a synchronous and dependable manner. By keeping our async "side-effects" within our epics we can leverage a simple test helper, expectEpic, to create concise and deterministic tests.

Usage

ES6

import {expectEpic} from 'redux-observable-test-helpers';

ES5

var helpers = require('redux-observable-test-helpers');
var expectEpic = helpers.expectEpic;

unpkg

 <script src="https://unpkg.com/redux-observable-test-helpers@1.3.22/dist/epic-helper.js"></script>
Signature

 /**
 * expectEpic - Test helper for redux-observable epics
 *
 * @param epic     - the redux-observable epic to test
 *{
 * @param action   - marble notation for the action the epic is listening for
 * @param call     - (optional) a local sinon.spy used to get/set/reset api calls
 * @param callArgs - (optional) An array containing the api method, followed by any params
 * @param done     - (optional) mocha callback for async tests
 * @param expected - marble notation for the expected result
 * @param replace  - (optional) allows replacement of fields using timestamps or other generated values
 * @param response - the expected payload
 * @param store    - (optional) a reference to the redux store
 *}
 */
 const expectEpic = (epic, {action, call, callArgs, done, expected, replace, response, store}) => {...};

expectEpic Examples

Alternative MockXMLHttpRequest approach

1.3.28

7 years ago

1.3.27

7 years ago

1.3.25

7 years ago

1.3.24

7 years ago

1.3.23

7 years ago

1.3.22

7 years ago

1.3.21

7 years ago

1.3.20

7 years ago

1.3.19

7 years ago

1.3.18

7 years ago

1.3.17

7 years ago

1.3.16

7 years ago

1.3.15

7 years ago

1.3.14

7 years ago

1.3.12

7 years ago

1.3.11

7 years ago

1.3.9

7 years ago

1.3.7

7 years ago

1.3.6

7 years ago

1.3.5

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.8

8 years ago

1.2.7

8 years ago

1.2.6

8 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago