Let's follow the given steps to create an API integration test for our Express web server's /api endpoint:
- First, we will create a new test file, called /test/integration/test-route-api.ts. This new integration folder helps us keep our tests organized logically in terms of their level of abstraction, while the naming convention reinforces the relationship of the tested content to the project's source code:
import { suite, test } from 'mocha-typescript';import * as chai from 'chai';const expect = chai.expect;@suite class API { }
- Before we can start writing integration tests, we need to instantiate our application to the state that we will need in order to run the test. For this API test, we will need to configure our application ...