Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eccenca/ecc-test-helpers

Eccenca javascript test helpers
https://github.com/eccenca/ecc-test-helpers

Last synced: about 1 month ago
JSON representation

Eccenca javascript test helpers

Awesome Lists containing this project

README

        

# Eccenca test helpers (ecc-test-helpers)

Offers a simple way to create an environment for testing.

Currently includes:

- [jsdom](https://github.com/tmpvar/jsdom) with [localStorage](https://github.com/lmaccherone/node-localstorage) for all your DOM needs
- [React](https://facebook.github.io/react/) and [TestUtils](https://facebook.github.io/react/docs/test-utils.html) (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](https://github.com/shouldjs/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:

```js

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(
{}}/>,
this.container
);
// ...
});
});
});
```