Skip to content

Commit

Permalink
docs(testing): provide performance tips for jest (#9128)
Browse files Browse the repository at this point in the history
explain which flags to use when running tests for the best performance in jest

ISSUES CLOSED: #8964
  • Loading branch information
barbados-clemens committed Mar 15, 2022
1 parent 9c25cd9 commit ac464b9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/shared/jest-plugin.md
Expand Up @@ -44,7 +44,12 @@ Replacing `<project-name>` with the name of the project you're wanting to add Je

### Testing Applications

Run the Jest test with
The recommended way to run/debug Jest tests via an editor

- [VSCode](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner)
- [Webstorm](https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/)

To run Jest tests via nx use

```shell
nx test frontend
Expand Down Expand Up @@ -83,6 +88,12 @@ nx test frontend -u

Snapshot files should be checked in with your code.

### Performance in CI

Typically, in CI it's recommended to use `nx affected --target=test --parallel=[# CPUs] -- --runInBand` for the best performance.

This is because each [jest process creates a workers based on system resources](https://jestjs.io/docs/cli#--maxworkersnumstring), running multiple projects via nx and using jest workers will create too many process overall causing the system to run slower than desired. Using the `--runInBand` flag tells jest to run in a single process.

## Configurations

### Jest
Expand Down

1 comment on commit ac464b9

@vercel
Copy link

@vercel vercel bot commented on ac464b9 Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.