Skip to content

Testing ReactComponents

andrerpena edited this page Mar 14, 2015 · 6 revisions

Unit tests are run through Node.js by default. So, the first thing to do is to make sure all Node modules are installed for the project. The Node modules are described in the package.json file. However, the modules themselves are not contained in this repo.

In order to download the Node dependencies according to the package.json file, in the ReactComponents root directory, run:

$ npm install

ReactComponents use Mocha as the test framework.

To install Mocha:

$ npm install -g mocha

This will make the mocha CLI globally available.

Running Mocha tests

To test ReactComponents, go to the root directory and simply type mocha. Mocha will automatically search for a directory called test and run all tests inside it, recursively.

You can also run Mocha in watch mode, meaning that, it will automatically listen to file changes and re-run the tests as any file changes. In order to run in watch mode, type mocha --watch.

If you are using WebStorm, you can run Mocha from the console (alt + F12):

Clone this wiki locally