Skip to content

jonathanglasmeyer/react-0-13-testing-mocha-jsdom-babel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testing React components with Mocha, Chai, JSDom, React 0.13 & Babel

mocha

This is a demo/proof of concept demonstrating how to test React components with React 0.13 style classes and babel (stage 0), using the idea of smart and dumb components for dependency injecting mock-data into the components we want to test via TestController components.

In this example there is an App component which gets its data as props from a AppTestController component, which has test data hardcoded in its state and serves as a data mock for testing. There would be another 'real' AppController getting its state via Flux/Actions/some API, but we don't care about this when we want to test React components in isolation.

how

npm test runs mocha in watch mode, loading the tests each time a test file or a component file changes. this is blazing fast (6-7ms). if the test suite grows, we could append .only to the describe- or it-block that we are currently testing. (see here for further explanation).

credit

forked/inspired by jesstelford/react-testing-mocha-jsdom. thanks!

About

Testing React components with Mocha, Chai, JSDom, React 0.13 and Babel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published