Gathering detailed insights and metrics for redux-actions-assertions
Gathering detailed insights and metrics for redux-actions-assertions
Gathering detailed insights and metrics for redux-actions-assertions
Gathering detailed insights and metrics for redux-actions-assertions
Simplify testing of redux action and async action creators
npm install redux-actions-assertions
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
188 Stars
100 Commits
11 Forks
5 Watchers
1 Branches
5 Contributors
Updated on May 09, 2023
Latest Version
1.3.0
Package Id
redux-actions-assertions@1.3.0
Size
4.26 kB
NPM Version
4.0.5
Node Version
6.9.1
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
1
Assertions for redux actions testing.
This library adds assertions for redux actions testing.
It use redux-mock-store to mock redux store.
If you have not found assertion framework/library that you are using - please add comment into this issue.
It allows to test only actions that need to be tested.
Example:
We have two actions (A, B). Each one makes async http requests.
Action A makes a request and if the result is successful it triggers Action B.
Action B is also used as an independent action.
Action B can be tested separately.
Therefore, we don't need to test it again in Action A.
Actions:
1function actionA() { 2 return dispatch => { 3 dispatch(actionAStart()); 4 return api.getA().then(response => { 5 dispatch(actionAFinish(response)); 6 dispatch(actionB()); 7 }).catch(err => { 8 dispatch(actionAFailure(err)); 9 }); 10 }; 11} 12 13function actionB() { 14 return dispatch => { 15 dispatch(actionBStart()); 16 return api.getB().then(response => { 17 dispatch(actionBFinish(response)); 18 }).catch(err => { 19 dispatch(actionBFailure(err)); 20 }); 21 }; 22}
Without:
1const expectedActions = [ 2 { type: action_a_start }, 3 { type: action_a_success }, 4 { type: action_b_start }, // retesting of action B 5 { type: action_b_success } // retesting of action B]; 6const store = mockStore({ todos: [] }); 7store.dispatch(actionA()).then(() => { 8 expect(store.getActions()).toEqual(expectedActions); 9}).then(done).catch(done);
With:
1expect(actionA()).withState({ todos: [] }).toDispatch([ 2 { type: action_a_start }, 3 { type: action_a_success }, 4 actionB() // just executing tested action 5], done);
It reduces boilerplate of test methods and makes testing fluent.
Without:
1const store = mockStore(/* initial state */); 2const expectedActions = [ 3 { type: types.FETCH_TODOS_REQUEST }, 4 /* All expected triggered action objects */ 5]; 6store.dispatch(fetchData()).then(() => { 7 const actions = store.getActions(); 8 expect(actions).toEqual(expectedActions); 9}).then(done).catch(done);
With:
1const expectedActions = [ 2 /*All expected triggered action objects or action creator functions*/ 3]; 4expect(fetchData()).toDispatchActions(expectedActions, done);
With using customised store state:
1expect(fetchData()).withState({/*custom state*/}).toDispatchActions(expectedActions, done);
It provides singe-time global configuration for middlewares and initial store state.
Without:
1const middlewares = [thunk]; 2const mockStore = configureStore(middlewares); 3const store = mockStore({ /*initial store object*});
With:
1registerMiddlewares([ thunk ]); 2// to set custom initial state 3registerInitialStoreState(/*object of function*/); 4// to generate initial state of your application 5registerInitialStoreState(buildInitialStoreState(/*your root reducer*/));
Using npm:
$ npm install --save-dev redux-actions-assertions
1// using ES6 modules 2import { registerMiddlewares } from 'redux-actions-assertions'; 3 4// using CommonJS modules 5var registerMiddlewares = require('redux-actions-assertions').registerMiddlewares; 6 7// registration 8registerMiddlewares([ 9 /* Here you need to list your middlewares */ 10]);
By using state object or function:
1// using ES6 modules 2import { registerInitialStoreState } from 'redux-actions-assertions'; 3 4// using CommonJS modules 5var registerInitialStoreState = require('redux-actions-assertions').registerInitialStoreState; 6 7// registration 8registerInitialStoreState(/* default initial state object or function */);
By using your root reducer:
1// using ES6 modules 2import { buildInitialStoreState, registerInitialStoreState } from 'redux-actions-assertions'; 3 4// using CommonJS modules 5var reduxActionsAssertions = require('redux-actions-assertions'); 6var registerInitialStoreState = reduxActionsAssertions.registerInitialStoreState; 7 8// registration 9registerInitialStoreState(buildInitialStoreState(/* root reducer function */));
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 3/9 approved changesets -- score normalized to 3
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
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
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