# Unit

To run jest tests with your config file just go to the root directory of your project and run

```bash
davinci-qa unit
```

Options:

- `--setupFilesAfterEnv` - a list of paths to global configuration files for jest tests
- `--anvilTag <anvil-project-tag>` - the project name matching [Anvil's expected tag](https://github.com/toptal/anvil/blob/2ea49649db605fc06492fcf346bdb0c56fff0769/app/models/test_result.rb#L10). Used to generate Anvil Reports.
- Any other jest option (ex. `--runInBand`)

### Running Unit tests on CI

Davinci provides functionality to run unit tests simultaneously. Davinci has a test [Sequencer](https://jestjs.io/docs/configuration#testsequencer-string) under the hood.

Example of execution unit tests in two separate threads:

```
GROUP_INDEX=0 GROUP_TOTAL=2 davinci-qa unit --ci
GROUP_INDEX=1 GROUP_TOTAL=2 davinci-qa unit --ci
```

To specify a Sequencer, need to specify two environment variables:

- `GROUP_INDEX` — The current worker index
- `GROUP_TOTAL` — Total amount of workers

[Jest CLI docs](https://jestjs.io/docs/en/cli)

[Tests are Failing and You Don't Know Why](https://github.com/facebook/jest/blob/master/docs/Troubleshooting.md#tests-are-failing-and-you-dont-know-why)
