Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/jeremija/react-testing

Reduces boilerplate code when testing React components
https://github.com/jeremija/react-testing

Last synced: 9 days ago
JSON representation

Reduces boilerplate code when testing React components

Awesome Lists containing this project

README

        

# react-testing

[![Build Status](https://travis-ci.org/jeremija/react-testing.svg?branch=master)][1]

Reduces boilerplate code when testing React components.

# Usage

Rendering using `react-addons-test-utils`:

```javascript
const { React, render } = require('react-testing');
const MyComponent = require('../MyComponent.jsx');
describe('MyComponent', () => {
it('should render without problems', () => {
const { component, node } = render(
test
);
expect(component.props.className).toBe('my-class');
expect(node.textContent).toBe('test');
});
});
```

Rendering using `react-test-renderer`:

```javascript
const { React, renderPure } = require('react-testing');
const MyComponent = require('../MyComponent.jsx');
describe('MyComponent', () => {
it('should render without problems', () => {
const obj = renderPure(
test
);
expect(obj.toJSON().children).toEqual(['test']);
});
});
```

# License
[ISC][2]

[1]: https://travis-ci.org/jeremija/react-testing
[2]: https://opensource.org/licenses/ISC