Commit 8ec99b6f authored by Blaine Kasten's avatar Blaine Kasten Committed by Dan Abramov
Browse files

Suggest jest-enzyme for simplifying test matchers (#994)

* Suggest jest-enzyme for simplifying test matchers

* Update README.md

* Update README.md
parent 12288836
Showing with 14 additions and 0 deletions
+14 -0
......@@ -867,6 +867,20 @@ it('renders welcome message', () => {
All Jest matchers are [extensively documented here](http://facebook.github.io/jest/docs/api.html#expect-value).<br>
Nevertheless you can use a third-party assertion library like [Chai](http://chaijs.com/) if you want to, as described below.
Additionally, you might find [jest-enzyme](https://github.com/blainekasten/enzyme-matchers) helpful to simplify your tests with readable matchers. The above `contains` code can be written simpler with jest-enzyme.
```js
expect(wrapper).toContainReact(welcome)
```
To setup jest-enzyme with Create React App, follow the instructions for [initializing your test environment](#initializing-test-environment) to import `jest-enzyme`.
```js
// src/setupTests.js
import 'jest-enzyme';
```
### Using Third Party Assertion Libraries
We recommend that you use `expect()` for assertions and `jest.fn()` for spies. If you are having issues with them please [file those against Jest](https://github.com/facebook/jest/issues/new), and we’ll fix them. We intend to keep making them better for React, supporting, for example, [pretty-printing React elements as JSX](https://github.com/facebook/jest/pull/1566).
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment