-
Book Overview & Buying
-
Table Of Contents
Node.js Blueprints
By :
Mocha is a little more advanced testing framework than Jasmine. It is more configurable, supports TDD or BDD testing, and even has several types of reporters. It is also quite popular and portable for client-side usage in the browser, which makes it a good candidate for our testing.
Similar to Jasmine, we need the Node.js's package manager to install Mocha. By running the following command, the framework will be set up globally:
npm install -g mocha
Once the installation finishes, we can run mocha ./tests. By default, the tool searches for JavaScript files and tries to run them. Here, let's use the same example used with Jasmine and pass it through Mocha. It actually uses the same syntax of the describe and it blocks. However, it doesn't come with its own assertion library. In fact, there is a built-in Node.js module for such purposes named assert. There are also libraries developed by other developers, for example, should.js, chai, or expect.js.
They differ...
Change the font size
Change margin width
Change background colour