Tests are a complex if not polemic topic. TDD or not TDD, not every automated test is an unit test, not every unit test needs to be automated. But frameworks have to be deployed to guarantee regression tests, which is how you know that the feature of fix being introduced now won’t break anything that was working perfectly before.


This project uses Mocha for that, only because it’s the one I learned first and always used in the past. I sincerely can’t say anything about the others but I’ll sure give Jest a try. It has increased its popularity this year and I ought to know why.


Mocha is a JavaScript testing framework, and the code to test is written in TypeScript. To make this work, we use ts-node, a TypeScript execution and REPL for node.js. In short, it transpiles the code on-the-fly, no need to build-ts or watch-ts. All you have to do is to add --require ts-node/register as a command line parameter.


To make the tests semantically pleasant, we use Chai. it’s an assertion library and has the sole function of turning this:

assert.equal(res.status, 200);

into this:

// or...

It may look foolish, but after a couple hundred tests, semantically pleasant code makes a difference.