Let's make those testing concepts more concrete by implementing some tests for the population service of WorldExplorer. To do so, we will use the Jest testing library.
Testing the population service of WorldExplorer
Installing and configuring Jest
First of all, we need to install Jest and the necessary additions:
- Install Jest using npm install jest --save-dev.
- Install the typings for Jest using npm install @types/jest --save-dev.
- Install the TypeScript preset for Jest using npm install ts-jest --save-dev.
We've used --save-dev because Jest will only be used during development.
We've installed ts-jest (https://kulshekhar.github.io/ts-jest), a preprocessor plugin for Jest that adds support for TypeScript and...