Nested Parenthetical Madness

    @virtuous/react-unit-test-suite

    1.2.0 • Public • Published

    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'
      }
    });

    Install

    npm i @virtuous/react-unit-test-suite

    DownloadsWeekly Downloads

    0

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    170 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar
    • avatar