0.2.0 • Published 6 years ago

jest-to-render-without-error v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

jest-to-render-without-error

CircleCI codecov Greenkeeper badge Npm

A Jest matcher to verify the render method of a React component

Installation

jest-to-render-without-error depends on Enzyme being installed as a peer dependency, please ensure enzyme is configured and available in your test environment.

yarn add jest-to-render-without-error --dev
npm install jest-to-render-without-error --save-dev

In your setupTestEnvironment.js

// src/setupTestEnvironment.js

require('jest-to-render-without-error')

Then in the "jest" section of your package.json add the following:

"setupTestFrameworkScriptFile": "<rootDir>/src/setupTestEnvironment.js"

Usage

expect(<MyCustomComponent propA={'A'} propB={true} />).toRenderWithoutError()

Test environment

jest-to-render-without-error behaves slightly differently depending on wether a DOM (such as JSDOM) is available at test time.

Without a DOM (the default) only the immediate components render method is tested, any errors or warnings in child components will not be reported.

Motivation

This matcher provides an easy way to ensure that the render method of your component will not cause any errors or warnings to be logged and returns without causing an exception.

This provides a lot of confidence that refactoring elsewhere in your codebase hasn't unintentionally broken your components.

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.0

7 years ago