Defining and controlling basic routes

As we mentioned previously, we will start this project by writing tests. To do so, let's create a folder called test and, in this folder, create a file called mocha.opts with the following content:

--require ts-node/register--require source-map-support/register--full-trace--bail--timeout 35000test/**/*.spec.ts

Those properties are going to configure Mocha with options such as timeout, the kind of files that will be used during the tests, and so on.

After that, create a folder called routes and, in this folder, create a file called index.spec.ts with the following content:

import * as chai from 'chai'import chaiHttp = require('chai-http')import 'mocha'import app from '../../src/app'chai.use(chaiHttp)

Get Hands-On RESTful Web Services with TypeScript 3 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.