O'Reilly logo

Node.js Blueprints by Krasimir Tsonev

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

Using Jasmine

Jasmine is a framework to test the JavaScript code. It is available as a Node.js module and also as a library, which we can use in the browser. It comes with its own assertion methods.

Installing Jasmine

We are going to use the Node.js version of the framework. It's a module, so it can be installed via the Node.js package manager, npm, as shown in the following code line:

npm install jasmine-node -g

The preceding command will set up Jasmine globally, so we can run jasmine-node in every directory of our choice. The tests could be organized into different files placed in one folder or in subfolders. The only requirement is to end the filenames with spec.js, for example, testing-payments.spec.js or testing-authorization.spec.js.

Defining ...

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