react-testing-helpers

1.1.1 • Public • Published

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

Package Sidebar

Install

npm i react-testing-helpers

Weekly Downloads

0

Version

1.1.1

License

MIT

Last publish

Collaborators

  • sonewman