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

Using frameworks

There are a couple of test frameworks available for Node.js. What they do is give you an environment where you can focus on the test cases. Some frameworks will even do code coverage more or less automatically.

One of the most commonly used frameworks is mocha, which is a simple yet powerful framework. It can be used for general unit testing, but also for performance, as it is able to highlight slow tests.

Let's try it out and prepare our microservice for the tests. You can use any of the previous versions; it should not matter for the storage model we're using, only the microservice interface. First of all, let's install mocha as a development dependency. We're also using an assertion library called chai, which has a plugin ...

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