In this guide we will see how you can run basic unit tests for a Strapi application using a testing framework.
::: tip
In this example we will use [Jest](https://jestjs.io/) Testing Framework with a focus on simplicity and
[Supertest](https://github.com/visionmedia/supertest) Super-agent driven library for testing node.js HTTP servers using a fluent API
:::
## Install test tools
`Jest` contains a set of guidelines or rules used for creating and designing test cases - a combination of practices and tools that are designed to help testers test more efficiently.
`Supertest` allows you to test all the `api` routes as they were instances of [http.Server](https://nodejs.org/api/http.html#http_class_http_server)
:::: tabs
::: tab yarn
`yarn add jest supertest`
:::
::: tab npm
`npm install jest supertest`
:::
Once this is done add this to `package.json` file
add `test` command to `scripts` section
```json
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi",
"test": "jest --forceExit --detectOpenHandles"
},
```
and add those line at the bottom of file
```json
"jest": {
"testPathIgnorePatterns": [
"/node_modules/",
".tmp",
".cache"
],
"testEnvironment": "node"
}
```
Those will inform `Jest` not to look for test inside the folder where it shouldn't.
::::
## Introduction
### Testing environment
Test framework must have a clean empty environment to perform valid test and also not to interfere with current database.
Once `jest` is running it uses the `test` [enviroment](../concepts/configurations.md#environments) (switching `NODE_ENV` to `test`)
so we need to create a special environment setting for this purpose.
Create a new config for test env `./config/env/test/database.json` and add the following value `"filename": ".tmp/test.db"`-the reason of that is that we want to have a separate sqlite database for tests, so our test will not touch real data.
In order to test anything we need to have a strapi instance that runs in the testing eviroment,
bascially we want to get instance of strapi app as object, similar like creating an instance for [process manager](process-manager).
These tasks require adding some files - let's create a folder `tests` where all the tests will be put and inside it, next to folder `helpers` where main Strapi helper will be in file strapi.js.