react-test-utilities

0.1.0 • Public • Published

react-test-utilities

Testing utilities for react.

npm install --save-dev react-test-utilities

renderAndFind(Component)

Renders a component into dom and returns that node.

var dom = renderAndFind(<Component/>);
expect(dom.text).toBe('Hello World.');

stubRouterContext(Component, props, stubs)

Stubs react-router's this.router.context so you can test components that rely on it.

import someReactRouterDependantComponent from 'components/someReactRouterDependantComponent';
 
var Subject = stubRouterContext(someReactRouterDependantComponent); 
var dom = renderAndFind(<Subject/>);
expect(someAssertion).toBe(true);

Readme

Keywords

Package Sidebar

Install

npm i react-test-utilities

Weekly Downloads

19

Version

0.1.0

License

ISC

Last publish

Collaborators

  • allanhortle