ecc-test-helpers

15.2.0 • Public • Published

Eccenca test helpers (ecc-test-helpers)

Offers a simple way to create an environment for testing.

Currently includes:

  • jsdom with localStorage for all your DOM needs
  • React and TestUtils (exposed via mocha this context)
  • Container for rendering your component that is create before each test and disposed afterwards (exposed via mocha context)
  • Should.js for your assertions (exposed as default module export)

Usage

  • Install module into your project (and save as dev deps) using npm install --save-dev ecc-test-helpers
  • Import the module in the beginning of your test suite using import should from 'ecc-test-helpers'
  • Access React, TestUtils and test container using this context, like so:
 
import should from 'ecc-test-helpers';
import Component from '../src/component';
 
describe('Component suite', function() {
    describe('Component', function() {
        it('Should render ...', function() {
            const React = this.React;
            const TestUtils = this.TestUtils;
 
            // render
            const comp = React.render(
                <TestComp handleModelSelect={() => {}}/>,
                this.container
            );
            // ...
        });
    });
});

Readme

Keywords

none

Package Sidebar

Install

npm i ecc-test-helpers

Weekly Downloads

0

Version

15.2.0

License

GPL-3.0

Last publish

Collaborators

  • haschek
  • ecc-admin