All Projects → redux-things → Redux Actions Assertions

redux-things / Redux Actions Assertions

Licence: mit
Simplify testing of redux action and async action creators

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Redux Actions Assertions

Sazerac
Data-driven unit testing for Jasmine, Mocha, and Jest
Stars: ✭ 322 (+81.92%)
Mutual labels:  jest, unit-testing, mocha, assertions
Enzyme
JavaScript Testing utilities for React
Stars: ✭ 19,781 (+11075.71%)
Mutual labels:  jest, mocha, assertions, chai
Aws Testing Library
Chai (https://chaijs.com) and Jest (https://jestjs.io/) assertions for testing services built with aws
Stars: ✭ 52 (-70.62%)
Mutual labels:  jest, assertions, chai
qa-automation-base
There are basic projects for automation frameworks based on Kotlin/Java and TypeScript for the backend, frontend, and mobile.
Stars: ✭ 45 (-74.58%)
Mutual labels:  mocha, jest, chai
Javascript Testing Best Practices
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)
Stars: ✭ 13,976 (+7796.05%)
Mutual labels:  jest, mocha, chai
chai-exclude
Exclude keys to compare from a deep equal operation with chai expect or assert.
Stars: ✭ 33 (-81.36%)
Mutual labels:  unit-testing, mocha, chai
patent-free-react-ecosystem-migration-plan
Patent Free React Ecosystem Migration Plan
Stars: ✭ 15 (-91.53%)
Mutual labels:  mocha, jest, chai
eslint-config-adjunct
A reasonable collection of plugins to use alongside your main esLint configuration
Stars: ✭ 39 (-77.97%)
Mutual labels:  mocha, jest, chai
tropic
🍍 Test Runner Library
Stars: ✭ 29 (-83.62%)
Mutual labels:  unit-testing, mocha, jest
awesome-javascript-testing
🔧 Awesome JavaScript testing resources
Stars: ✭ 28 (-84.18%)
Mutual labels:  unit-testing, mocha, jest
Snap Shot
Jest-like snapshot feature for the rest of us, works magically by finding the right caller function
Stars: ✭ 170 (-3.95%)
Mutual labels:  jest, unit-testing, mocha
Jest Codemods
Codemods for migrating to Jest https://github.com/facebook/jest 👾
Stars: ✭ 731 (+312.99%)
Mutual labels:  jest, mocha, chai
Earl
☕ Ergonomic, modern and type-safe assertion library for TypeScript
Stars: ✭ 153 (-13.56%)
Mutual labels:  jest, mocha, chai
Openapivalidators
Use Jest or Chai to assert that HTTP responses satisfy an OpenAPI spec
Stars: ✭ 77 (-56.5%)
Mutual labels:  jest, chai
Bombanauts
Bombanauts, inspired by the original Bomberman game, is a 3D multiplayer online battle arena (MOBA) game where players can throw bombs at each other, make boxes explode, and even other players!
Stars: ✭ 54 (-69.49%)
Mutual labels:  mocha, chai
React Base
atSistemas React/Redux Isomorphic Platform
Stars: ✭ 82 (-53.67%)
Mutual labels:  mocha, chai
Typescript Restful Starter
Node.js + ExpressJS + Joi + Typeorm + Typescript + JWT + ES2015 + Clustering + Tslint + Mocha + Chai
Stars: ✭ 97 (-45.2%)
Mutual labels:  mocha, chai
Karma Webpack Example
Karma + Webpack + Mocha + Chai + Istanbul
Stars: ✭ 88 (-50.28%)
Mutual labels:  mocha, chai
Jest Extended
Additional Jest matchers 🃏💪
Stars: ✭ 1,763 (+896.05%)
Mutual labels:  jest, assertions
Lode
A universal GUI for unit testing
Stars: ✭ 51 (-71.19%)
Mutual labels:  jest, unit-testing

redux-actions-assertions

Assertions for redux actions testing.

This library adds assertions for redux actions testing.
It use redux-mock-store to mock redux store.

build status npm version

Supported Assertion Frameworks/Libraries:

If you have not found assertion framework/library that you are using - please add comment into this issue.

What it does:

Allows to avoid retesting nested action creators

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:

function actionA() {
  return dispatch => {
    dispatch(actionAStart());
    return api.getA().then(response => {
        dispatch(actionAFinish(response));
        dispatch(actionB());
      }).catch(err => {
        dispatch(actionAFailure(err));
      });
    };
}

function actionB() {
  return dispatch => {
    dispatch(actionBStart());
    return api.getB().then(response => {
        dispatch(actionBFinish(response));
      }).catch(err => {
        dispatch(actionBFailure(err));
      });
    };
}

Without:

const expectedActions = [
  { type: action_a_start },
  { type: action_a_success },   
  { type: action_b_start }, // retesting of action B
  { type: action_b_success } // retesting of action B];
const store = mockStore({ todos: [] });
store.dispatch(actionA()).then(() => {
  expect(store.getActions()).toEqual(expectedActions);
}).then(done).catch(done);

With:

expect(actionA()).withState({ todos: [] }).toDispatch([
  { type: action_a_start },
  { type: action_a_success },
  actionB() // just executing tested action
], done);

Reduces repetitive code of test methods

It reduces boilerplate of test methods and makes testing fluent.

Without:

const store = mockStore(/* initial state */);
const expectedActions = [
  { type: types.FETCH_TODOS_REQUEST },
  /* All expected triggered action objects */
];
store.dispatch(fetchData()).then(() => {
  const actions = store.getActions();
  expect(actions).toEqual(expectedActions);
}).then(done).catch(done);

With:

const expectedActions = [
  /*All expected triggered action objects or action creator functions*/
];
expect(fetchData()).toDispatchActions(expectedActions, done);

With using customised store state:

expect(fetchData()).withState({/*custom state*/}).toDispatchActions(expectedActions, done);

Simplifies initial setup

It provides singe-time global configuration for middlewares and initial store state.

Without:

const middlewares = [thunk];
const mockStore = configureStore(middlewares);
const store = mockStore({ /*initial store object*});

With:

registerMiddlewares([ thunk ]);
// to set custom initial state 
registerInitialStoreState(/*object of function*/);
// to generate initial state of your application
registerInitialStoreState(buildInitialStoreState(/*your root reducer*/));

Installation

Using npm:

$ npm install --save-dev redux-actions-assertions

Redux middlewares registration

// using ES6 modules
import { registerMiddlewares } from 'redux-actions-assertions';

// using CommonJS modules
var registerMiddlewares = require('redux-actions-assertions').registerMiddlewares;

// registration
registerMiddlewares([
  /* Here you need to list your middlewares */
]);

Default initial store state registration

By using state object or function:

// using ES6 modules
import { registerInitialStoreState } from 'redux-actions-assertions';

// using CommonJS modules
var registerInitialStoreState = require('redux-actions-assertions').registerInitialStoreState;

// registration
registerInitialStoreState(/* default initial state object or function */);

By using your root reducer:

// using ES6 modules
import { buildInitialStoreState, registerInitialStoreState } from 'redux-actions-assertions';

// using CommonJS modules
var reduxActionsAssertions = require('redux-actions-assertions');
var registerInitialStoreState = reduxActionsAssertions.registerInitialStoreState;

// registration
registerInitialStoreState(buildInitialStoreState(/* root reducer function */));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].