https://github.com/jerry-hong/redux-observable-test-helper
redux-observable unit test helper function
https://github.com/jerry-hong/redux-observable-test-helper
redux redux-observable rxjs rxjs5 testing
Last synced: about 2 months ago
JSON representation
redux-observable unit test helper function
- Host: GitHub
- URL: https://github.com/jerry-hong/redux-observable-test-helper
- Owner: Jerry-Hong
- Created: 2017-09-20T19:32:14.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-04T13:02:32.000Z (over 7 years ago)
- Last Synced: 2025-05-02T15:13:10.710Z (about 2 months ago)
- Topics: redux, redux-observable, rxjs, rxjs5, testing
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/redux-observable-test-helper
- Size: 11.7 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# redux-observable-test-helper
## install
This has peer dependencies of rxjs 5 and redux-observable, which will have to be installed as well.
```bash
npm install --save-dev redux-observable-test-helper
```## Usage
```javascript
// epic.js
export const show = () => ({
type: 'SHOW',
});export const close = data => ({
type: 'CLOSE',
payload: data,
});export const delayEpic = action$ =>
action$.ofType('SHOW').delay(3000).map(x => close());
``````javascript
// epic.test.js
import {
delayEpic,
show,
close,
} from './epic.js';
import { createExpectedEpic, mockDelay } from 'redux-observable-test-helper';const expectedEpic = createExpectedEpic((actual, expected) => {
// here use Jest, you can use your assertion library
expect(actual).toEqual(expected);
});test('test delay', () => {
expectedEpic(
delayEpic,
{
expect: ['--a', { a: close() }],
action: ['a', { a: show() }],
},
mockDelay('--|')
);
});
```## API docs
[read here](https://github.com/Jerry-Hong/redux-observable-test-helper/blob/master/doc/API.md)