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:
- Create a subdirectory called
app
with anindex.html
file inside. Leave theindex.html
file blank as of now. - Create a file inside the
test
directory namedtestMyapp.js
. - Create a file
app.js
to add our application code. Theserverside-testing
application directory structure will now look like this: - 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.