feat(docs): add tips for running Jest CLI (#6308)
Include running tests from a specific file and running a particular test in a file Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
parent
df63380a82
commit
385614d20d
@ -190,6 +190,36 @@ When debugging the CMS with Git Gateway you must:
|
||||
4. Refresh the page
|
||||
5. You should be able to log in via your Netlify Identity email/password
|
||||
|
||||
### Fine tune the way you run unit tests
|
||||
|
||||
There are situations where you would want to run a specific test file, or tests that match a certain pattern.
|
||||
|
||||
To run all the tests for a specific file, use this command:
|
||||
|
||||
```
|
||||
yarn jest <filename or file path>
|
||||
```
|
||||
|
||||
The first part of the command, `yarn jest` means running the locally installed version of `jest`. It is equivalent to running `node_modules/.bin/jest`.
|
||||
|
||||
Example for running all the tests for the file `gitlab.spec.js`: `yarn jest gitlab.spec.js`
|
||||
|
||||
Some test files like `API.spec.js` is available in several packages. You can pass a regexp pattern instead of file path to narrow down files.
|
||||
|
||||
Example for running all the tests for the file `API.spec.js` in the `netlify-cms-backend-gitlab` package:
|
||||
|
||||
`yarn jest ".+backend-gitlab/.+/API.spec.js`
|
||||
|
||||
To run a specific test in a file, add the flag `--testNamePattern`, or `-t` for short followed by a regexp to match your test name.
|
||||
|
||||
Example for running the test "should return true on project access_level >= 30" in the API.spec.js in `netlify-cms-backend-gitlab` package:
|
||||
|
||||
```
|
||||
yarn jest -t "true on p" ".+backend-gitlab/.+/API.spec.js"
|
||||
```
|
||||
|
||||
For more information about running tests exactly the way you want, check out the official documentation for [Jest CLI](https://jestjs.io/docs/cli).
|
||||
|
||||
## License
|
||||
|
||||
By contributing to Netlify CMS, you agree that your contributions will be licensed
|
||||
|
Loading…
x
Reference in New Issue
Block a user