O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing in the server

The first thing you need when testing JavaScript applications is a test-runner.

The test-runner is the program that gives you the tools to create your tests, executes them, and provide the test results. One very famous test-runner for Node.js is called mocha, and this is the runner we will be using in this book when doing tests on the server.

First, we need to install it using the following command:

    npm install mocha@3.2.0 -save-dev

Now let's create a basic test to see how it works:

var assert = require('assert'); describe('Math test', function() {   it('should return -1 when evaluating the minimum between -1 and 1', function() {     assert.equal(-1, Math.min(-1,1));   });  it('should return 1 when evaluating the maximum ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required