Testing react’s dom with jest and enzyme

Install it like this:

Then configure your enzyme to work with react 16. Add to package.json:

If you are using create-react-app, then you should not override package.json but create a file in default location instead, which is src/setupTests.js.
Anyways, the content of the file should be as follows:

The main idea is:

OR

https://facebook.github.io/jest/docs/en/tutorial-react.html
https://github.com/airbnb/enzyme/issues/1265
https://stackoverflow.com/a/46810504/801426
All matchers can be found here — https://jest-bot.github.io/jest/docs/expect.html

Similar Posts

LEAVE A COMMENT