Gathering detailed insights and metrics for redux-logic-test
Gathering detailed insights and metrics for redux-logic-test
Gathering detailed insights and metrics for redux-logic-test
Gathering detailed insights and metrics for redux-logic-test
redux-logic test utilities to facilitate the testing of logic. Create mock store
npm install redux-logic-test
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
37 Stars
24 Commits
3 Forks
5 Watchers
1 Branches
1 Contributors
Updated on Sep 17, 2020
Latest Version
2.0.0
Package Id
redux-logic-test@2.0.0
Unpacked Size
28.96 kB
Size
7.18 kB
File Count
12
NPM Version
6.4.1
Node Version
10.10.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
2
39
"Simplifying testing with redux-logic"
Utilities:
createMockStore
- create a redux-logic middleware and a redux store, attaching the middleware and providing a mechanism to verify the dispatched actionsredux-logic-test has peerDependencies of redux and redux-logic (which also needs rxjs)
1npm install rxjs --save 2npm install redux-logic --save 3npm install redux --save 4npm install redux-logic-test --save-dev
1import { createMockStore } from 'redux-logic-test';
1const createMockStore = require('redux-logic-test').default.createMockStore;
The UMD build is mainly used for using in online playgrounds like jsfiddle.
1<script src="https://npmcdn.com/redux@%5E3.6.0/dist/redux.min.js"></script> 2<script src="https://unpkg.com/redux-logic@%5E0.11.6/dist/redux-logic.min.js"></script> 3<script src="https://unpkg.com/redux-logic-test@%5E1.0.1/dist/redux-logic-test.min.js"></script> 4<script type="text/javascript"> 5 const { createLogic } = ReduxLogic; 6 const { createMockStore } = ReduxLogicTest; 7 // ready to use createMockStore 8</script>
1 import { createMockStore } from 'redux-logic-test';
2
3 // specify as much as necessary for your particular test
4 const store = createMockStore({
5 initialState: optionalObject,
6 reducer: optionalFn, // default: identity reducer
7 logic: optionalLogic, // default: []
8 injectedDeps: optionalObject, // default {}
9 middleware: optionalArr // other mw, exclude logicMiddleware
10 });
11
12 store.dispatch(...) // use as necessary for your test
13
14 // when all inflight logic has all completed calls fn + returns promise
15 store.whenComplete(fn) - shorthand for store.logicMiddleware.whenComplete(fn)
16
17 store.actions - the actions dispatched, use store.resetActions() to clear
18 store.resetActions() - clear store.actions
19
20 // access the logicMiddleware created for logic/injectedDeps props
21 // use addLogic, mergeNewLogic, replaceLogic, whenComplete, monitor$
22 store.logicMiddleware
1import { createMockStore } from 'redux-logic-test'; 2import { createLogic } from 'redux-logic'; 3 4const fooLogic = createLogic({ 5 type: 'FOO', 6 process({ API, getState, action }, dispatch, done) { 7 API.get(...) 8 .then(results => { 9 dispatch({ type: 'FOO_SUCCESS', payload: results }); 10 done(); 11 }); 12 } 13}); 14 15const logic = [fooLogic]; // array of logic to use/test 16const injectedDeps = { // include what is needed for logic 17 API: api // could include mocked API for easy testing 18}; 19 20const initialState = {}; // optionally set 21const reducer = (state, action) => { return state; }; // optional 22 23const store = createMockStore({ 24 initialState, 25 reducer, 26 logic, 27 injectedDeps 28}); 29 30store.dispatch({ type: 'FOO' }); // kick off fetching 31store.dispatch({ type: 'BAR' }); // other dispatches 32store.whenComplete(() => { // runs this fn when all logic is complete 33 expect(store.getState()).toEqual({...}); 34 expect(store.actions).toEqual([ 35 { type: 'FOO' }, 36 { type: 'BAR' }, 37 { type: 'FOO_SUCCESS', payload: [...] } 38 ]); 39 // if desired, can reset the actions for more tests 40 // store.resetActions(); // clear for more tests 41 42 // be sure to return the whenComplete promise to your test 43 // or if using a done cb, call it to indicate that your async 44 // test is finished 45});
If you have input or ideas or would like to get involved, you may:
This project is supported by CodeWinds Training
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
140 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More