Skip to content

Commit

Permalink
Update instructions for Jest versions 15+
Browse files Browse the repository at this point in the history
  • Loading branch information
vjwilson authored and ljharb committed Oct 29, 2016
1 parent 93eeaac commit 772e251
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions docs/guides/jest.md
@@ -1,7 +1,27 @@
# Using Jest with Enzyme

If you are using Jest 0.9+ with enzyme and using Jest's automocking feature, you will need to mark
react and enzyme to be unmocked in your `package.json`:
## Jest version 15 and up

Starting with version 15, Jest [no longer mocks modules by default](https://facebook.github.io/jest/blog/2016/09/01/jest-15.html). Because of this, you no longer have to add _any_ special configuration for Jest to use it with Enzyme.

Install Jest, and its Babel integrations, as recommended in the [Jest docs](https://facebook.github.io/jest/docs/getting-started.html). Install Enzyme. Then, simply require/import React, Enzyme functions, and your module at the top of a test file.

```js
import React from 'react';
import { shallow, mount, render } from 'enzyme';

import Foo from '../Foo';
```

You do **not** need to include Jest's own renderer, unless you want to use it _only_ for Jest snapshot testing.

## Example Project for Jest prior to version 15

- [Example test for Jest 15+](https://github.com/vjwilson/enzyme-example-jest)

## Jest prior to version 15

If you are using Jest 0.9 – 14.0 with Enzyme and using Jest's automocking feature, you will need to mark react and enzyme to be unmocked in your `package.json`:

```js
/* package.json */
Expand All @@ -16,6 +36,6 @@ react and enzyme to be unmocked in your `package.json`:

If you are using a previous version of Jest together with npm3, you may need to unmock [more modules](https://github.com/airbnb/enzyme/blob/78febd90fe2fb184771b8b0356b0fcffbdad386e/docs/guides/jest.md).

## Example Projects
## Example Project for Jest prior to version 15

- [enzyme-example-jest](https://github.com/lelandrichardson/enzyme-example-jest)

0 comments on commit 772e251

Please sign in to comment.