

Our project’s structure will contain an app directory that with the main code, and a test directory with the Mocha test files: $ mkdir app

"test": "echo \"Error: no test specified\" & exit 1" Npm’s init command-line option will launch a wizard, which creates a package.json for our project.įor the purpose of this tutorial, answer its questions as follows: $ npm init Node’s official package manager - npm - will help us set up an empty project. We will start by creating an empty directory.

In addition, we will create a web server that exposes the above converter and demonstrates how to test asynchronous code. This article will walk you through its installation and configuration, as well as demonstrate its usage by implementing a color converter that can translate from RGB (red, green, blue) to hexadecimal color representation. It’s used for unit and integration testing, and it’s a great candidate for BDD (Behavior Driven Development). Mocha is a testing library for Node.js, created to be a simple, extensible, and fast.
