@virtuous/react-unit-test-suite

A unit test suite configured for testing in an react.js environment.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
00Dec 19, 2018Nov 14, 2017Minified + gzip package size for @virtuous/react-unit-test-suite in KB

Readme

Virtuous' React Unit Test Suite

GitHub release License: MIT

This test suite is a configuration for ReactJS projects.

This configuration uses Jest for running the tests. It is only an extension of the default Jest configuration and prepares your tests for any React.js application.

Installation

npm i --save-dev @virtuous/react-unit-test-suite react react-dom

Usage

All test files should follow the naming convention of *(spec|test).(js|jsx).

You have two options of how to create a configuration for Jest:

  • You can create your own configuration following the Jest Documentation
  • You can use Virtuous' pre-defined configuration and extend it as you wish.

NOTE: Using and extending the Virtuous configuration is the preferred way!

1. Using Virtuous' configuration

Create a file called jest.config.js in the root of your project. Add the following line to it:

module.exports = require('@virtuous/react-unit-test-suite/jest.config');

2. Extending Virtuous' configuration

Create a file called jest.config.js in the root of your project. Add the following line in the beginning of the file:

const defaultConfig = require('@virtuous/react-unit-test-suite/jest.config');

This will load the default configuration. Now you can extend it by spreading the defaultConfig into a newly created configuration object:

ES2015 / ES6 / ES2017 / ES.Next (recommended)

module.exports = {
  ...defaultConfig,
  [Your config goes here],
};

CommonJS

module.exports = Object.assign({}, defaultConfig, {
  [Your config goes here]
});

Example Configuration

Here is an example showing how to extend the default configuration:

ES2015 / ES6 / ES2017 / ES.Next

const defaultConfig = require('@virtuous/react-unit-test-suite/jest.config');

module.exports = {
  ...defaultConfig,
  moduleNameMapper: {
    '^Components(.*)$': '<rootDir>/components',
    '^Styles(.*)$': '<rootDir>/styles',
  },
};

CommonJS

const defaultConfig = require('@virtuous/react-unit-test-suite/jest.config');

module.exports = Object.assign({}, defaultConfig, {
  moduleNameMapper: {
    '^Components(.*)$': '<rootDir>/components',
    '^Styles(.*)$': '<rootDir>/styles'
  }
});

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.