react-testing
v1.0.6
Published
Reduces boilerplate code when testing react components.
Downloads
283
Maintainers
Readme
react-testing
Reduces boilerplate code when testing React components.
Usage
Rendering using react-addons-test-utils
:
const { React, render } = require('react-testing');
const MyComponent = require('../MyComponent.jsx');
describe('MyComponent', () => {
it('should render without problems', () => {
const { component, node } = render(
<MyComponent className="my-class">test</MyComponent>
);
expect(component.props.className).toBe('my-class');
expect(node.textContent).toBe('test');
});
});
Rendering using react-test-renderer
:
const { React, renderPure } = require('react-testing');
const MyComponent = require('../MyComponent.jsx');
describe('MyComponent', () => {
it('should render without problems', () => {
const obj = renderPure(
<MyComponent className="my-class">test</MyComponent>
);
expect(obj.toJSON().children).toEqual(['test']);
});
});