Structuring the codebase for tests
As we write more tests for our application, we'll benefit from having more structure to our tests. It's common to have at least one test file per production module. It will also be useful to have a way of running all of our tests and seeing the overall result.
We're going to start adding tests under a test
directory. From this point on in the book, we're also going to keep all of our application code under a src
directory. This will make it easier to navigate our codebase and to keep production and test code separate.
If you're following along with the book at this point, you should move app.js
and all the folders (apart from the bin
folder) under a new src
directory, and update the startup script as follows in bin/www
:
var app = require('../src/app');
var debug = require('debug')('hangman:server');
var http = require('http');