Introducing Mocha

Mocha is a modern test runner that can be executed from Node as well as inside a browser. As we saw earlier, our main approach is to use Node. In this book, I am using Mocha Version 1.20.1, but any 1.x version should be OK.

We have already installed Mocha using NPM, so we can run it with the following command:

$ me@~/validator> ./node_modules/.bin/mocha -u bdd -R spec -t 500 --recursive

It fails because we do not have any test yet; we will fix it later. I will explain the exact meaning of these parameters in a moment. For now, note that, to execute Mocha, we need to find out where NPM has installed the executable of the tool. A package can be a simple library, or it can also contain an executable command-line tool, as is the ...

Get Learning Behavior-driven Development with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.