chai-react-assertions
Helper assertions for Chai which makes it easier to test React components.
Installation
$ npm install chai-react-assertions --save-dev
Example usage
chai const renderedTree = tocontain === truetocontain === true
API
Top level API
shallowRender(JSX)
Returns an instance of a React tree using the skin-deep library.
Chai assertions
.elementWithText(textToFind: string)
Tries to find the given text in the rendered children. This will be able to find text which spans across multiple elements, for example:
const renderedTree = tocontain === true
.elementWithProps(selector: string, props: object?)
Tries to find a rendered component with the given selector and props.
The selector can be the display name of a component, or *
to catch all component types which will find any element based on props.
.numberOfElements(selector: string, count: number)
TODO
.elementWithStyledText(textToFind: string, style: object|array)
TODO
License
Licensed under the MIT License.
View the full license here.