react-testing-helpers
v1.1.1
Published
Simple helpers for testing react
Downloads
4
Readme
React Testing Helpers
Simple testing helpers for React.
Usage
import * as testHelpers from 'react-testing-helpers';
testingHelpers.shallowRender(jsx)
Helper to automatically shallowRender
the given jsx
import {shallowRender} from 'react-testing-helpers';
const output = shallowRender(
<MyComponent>
<MyOtherComponent/>
</MyComponent>
);
testingHelpers.renderFakeDom(jsx)
Helper takes jsx output from renderToString
and loads it into cheerio
.
This then allows for the output to be queried in a similar fashion to jQuery.
import {renderFakeDom} from 'react-testing-helpers';
const $ = shallowRender(
<MyComponent>
<div/>
</MyComponent>
);
expect($('div').length).toEqual(1);
Licence
MIT