Server-side unit testing

In the previous example, we saw a way to start and run our test in Mocha. Server-side testing is important, because it helps you to know your code quality, speed, services request, and response time.

Implementing the web server

For a server-side support, we need to implement an HTTP server, which will serve our requests. Follow the points here to add a web server in our application:

  1. Create a subdirectory called app with an index.html file inside. Leave the index.html file blank as of now.
  2. Create a file inside the test directory named testMyapp.js.
  3. Create a file app.js to add our application code. The serverside-testing application directory structure will now look like this:
  4. Before we write any production code, let's write a ...

Get Test-Driven JavaScript Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.