Configuring test tools
The first thing we need to do is install the required tools necessary for testing our Strapi application. The first library we need is Jest. Jest is a JavaScript library developed and maintained by Facebook; it is mainly used for unit testing. Let's get started, as follows:
- To install Jest, launch your terminal and execute the following command:
yarn add -D jest
This command will install Jest for us. Notice that we have used the -D
flag when installing the library. This flag is used to indicate that the library we are about to install is a development library. We only need it while we are developing and working on the application, but we do not need it in the production environment since tests are run and executed before we package and ship the application.
Jest is great to test the functionality of our API components such as controller logic or utility functions, but we cannot use it to test HyperText Transfer Protocol (HTTP) requests...