15.2.0 • Published 7 years ago
ecc-test-helpers v15.2.0
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
);
// ...
});
});
});