Kent C. Dodds

Utah

1 wife, 3 kids

PayPal, Inc.

@kentcdodds

Testing React

with Mocha, Enzyme, and Chai

Please Stand...

What this talk is

  • Some contrived examples
  • Live coding
  • Suggestions and recommendations

What this talk is not

  • Everything there is to know about Mocha
  • Everything there is to know about Enzyme
  • Everything there is to know about React

Let's
Get
STARTED!

What are these things?

Mocha: Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser.

Enzyme: A JavaScript Testing utility for React that makes it easier to assert, manipulate, and traverse your React Components' output.

Chai: Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.

chai-enzyme: Chai.js assertions for enzyme.

Sinon: Standalone test spies, stubs, and mocks for JS.

sinon-chai: Chai.js assertions for sinon.

Testing React

Data

User

Props

Four inputs to React Components

Context

Component

$ git clone https://github.com/kentcdodds/react-mocha-workshop.git

$ cd react-mocha-workshop

$ git checkout start

$ npm install

Now open the INSTRUCTIONS.md up in your favorite editor...

Let's get set up

Thank you!