O'Reilly logo

Hands-On Microservices with Node.js by Diogo Resende

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

Integrating tests

We will now create our first integration tests. Each of our tests will run separately, meaning they should not depend on any other test and should follow a predictable workflow. First, we need to change our run.js file to run all test files. For that, we'll use mocha and add all files found in the integration folder:

const fs    = require("fs");const path  = require("path");const mocha = require("mocha");const suite = new mocha();fs.readdir(path.join(__dirname, "integration"), (err, files) => {    if (err) throw err;    files.filter((filename) =>     (filename.match(/\.js$/))).map((filename) => {        suite.addFile(path.join(__dirname, "integration", filename));    });    suite.run((failures) => {        process.exit(failures);    });});

Then, let's create ...

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