How it works...

The Mocha test runner uses ts-node to load our TypeScript test files, compiles them to JavaScript, and executes them. The files are then evaluated for their suite context, and each test within the suite is evaluated in sequence. The actual test is incredibly fast itself due, in large part, to the extensive mocking we are doing for the Express application request and response behaviors.

Our test assertions are written using the expect keyword from Chai, followed by a series of very readable chain methods for what the expected values should be. These assertions are very useful and flexible for composing the test criteria you want to assert. The Chai assertions library includes dozens of different assertions that can be composed ...

Get MEAN Cookbook 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.