Skip to content

Commit

Permalink
docs: add few missing admonitions to the CLI Options page (#13894)
Browse files Browse the repository at this point in the history
Co-authored-by: Seong Min Park <psm03120@gmail.com>
  • Loading branch information
mrazauskas and notoriousmango committed Feb 11, 2023
1 parent 2818bf1 commit f9f7d79
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/CLI.md
Expand Up @@ -437,7 +437,7 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

:::tip

Expand Down
10 changes: 5 additions & 5 deletions website/versioned_docs/version-25.x/CLI.md
Expand Up @@ -124,7 +124,7 @@ Alias: `-b`. Exit the test suite immediately upon `n` number of failing test sui

Whether to use the cache. Defaults to true. Disable the cache using `--no-cache`.

:::note
:::caution

The cache should only be disabled if you are experiencing caching related problems. On average, disabling the cache makes Jest at least two times slower.

Expand Down Expand Up @@ -226,7 +226,7 @@ Find and run the tests that cover a space separated list of source files that we

Force Jest to exit after all tests have completed running. This is useful when resources set up by test code cannot be adequately cleaned up.

:::note
:::caution

This feature is an escape-hatch. If Jest doesn't exit at the end of a test run, it means external resources are still being held on to or timers are still pending in your code. It is advised to tear down external resources after each test to make sure Jest can shut down cleanly. You can use `--detectOpenHandles` to help track it down.

Expand Down Expand Up @@ -363,9 +363,9 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `"GET /api/posts with auth"`, then you can use `jest -t=auth`.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

:::note
:::tip

The regex is matched against the full name, which is a combination of the test name and all its surrounding describe blocks.

Expand Down Expand Up @@ -417,7 +417,7 @@ Watch files for changes and rerun tests related to changed files. If you want to

Watch files for changes and rerun all tests when something changes. If you want to re-run only the tests that depend on the changed files, use the `--watch` option.

Use `--watchAll=false` to explicitly disable the watch mode. N
Use `--watchAll=false` to explicitly disable the watch mode.

:::tip

Expand Down
50 changes: 42 additions & 8 deletions website/versioned_docs/version-26.x/CLI.md
Expand Up @@ -98,7 +98,11 @@ jest --update-snapshot --detectOpenHandles

## Options

_Note: CLI options take precedence over values from the [Configuration](Configuration.md)._
:::note

CLI options take precedence over values from the [Configuration](Configuration.md).

:::

import TOCInline from '@theme/TOCInline';

Expand All @@ -118,7 +122,13 @@ Alias: `-b`. Exit the test suite immediately upon `n` number of failing test sui

### `--cache`

Whether to use the cache. Defaults to true. Disable the cache using `--no-cache`. _Note: the cache should only be disabled if you are experiencing caching related problems. On average, disabling the cache makes Jest at least two times slower._
Whether to use the cache. Defaults to true. Disable the cache using `--no-cache`.

:::caution

The cache should only be disabled if you are experiencing caching related problems. On average, disabling the cache makes Jest at least two times slower.

:::

If you want to inspect the cache, use `--showConfig` and look at the `cacheDirectory` value. If you need to clear the cache, use `--clearCache`.

Expand All @@ -136,7 +146,13 @@ When this option is provided, Jest will assume it is running in a CI environment

### `--clearCache`

Deletes the Jest cache directory and then exits without running tests. Will delete `cacheDirectory` if the option is passed, or Jest's default cache directory. The default cache directory can be found by calling `jest --showConfig`. _Note: clearing the cache will reduce performance._
Deletes the Jest cache directory and then exits without running tests. Will delete `cacheDirectory` if the option is passed, or Jest's default cache directory. The default cache directory can be found by calling `jest --showConfig`.

:::caution

Clearing the cache will reduce performance.

:::

### `--clearMocks`

Expand Down Expand Up @@ -204,7 +220,13 @@ Find and run the tests that cover a space separated list of source files that we

### `--forceExit`

Force Jest to exit after all tests have completed running. This is useful when resources set up by test code cannot be adequately cleaned up. _Note: This feature is an escape-hatch. If Jest doesn't exit at the end of a test run, it means external resources are still being held on to or timers are still pending in your code. It is advised to tear down external resources after each test to make sure Jest can shut down cleanly. You can use `--detectOpenHandles` to help track it down._
Force Jest to exit after all tests have completed running. This is useful when resources set up by test code cannot be adequately cleaned up.

:::caution

This feature is an escape-hatch. If Jest doesn't exit at the end of a test run, it means external resources are still being held on to or timers are still pending in your code. It is advised to tear down external resources after each test to make sure Jest can shut down cleanly. You can use `--detectOpenHandles` to help track it down.

:::

### `--help`

Expand All @@ -228,7 +250,11 @@ test('some test', () => {
});
```

_Note: This option is only supported using `jest-circus`._
:::note

This option is only supported using the default `jest-circus` test runner.

:::

### `--json`

Expand Down Expand Up @@ -312,7 +338,11 @@ Alias: `-i`. Run all tests serially in the current process, rather than creating

Run only the tests that were specified with their exact paths.

_Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_
:::tip

The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files.

:::

### `--selectProjects <project1> ... <projectN>`

Expand Down Expand Up @@ -353,9 +383,13 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `"GET /api/posts with auth"`, then you can use `jest -t=auth`.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

_Note: The regex is matched against the full name, which is a combination of the test name and all its surrounding describe blocks._
:::tip

The regex is matched against the full name, which is a combination of the test name and all its surrounding describe blocks.

:::

### `--testPathIgnorePatterns=<regex>|[array]`

Expand Down
52 changes: 43 additions & 9 deletions website/versioned_docs/version-27.x/CLI.md
Expand Up @@ -98,7 +98,11 @@ jest --update-snapshot --detectOpenHandles

## Options

_Note: CLI options take precedence over values from the [Configuration](Configuration.md)._
:::note

CLI options take precedence over values from the [Configuration](Configuration.md).

:::

import TOCInline from '@theme/TOCInline';

Expand All @@ -118,7 +122,13 @@ Alias: `-b`. Exit the test suite immediately upon `n` number of failing test sui

### `--cache`

Whether to use the cache. Defaults to true. Disable the cache using `--no-cache`. _Note: the cache should only be disabled if you are experiencing caching related problems. On average, disabling the cache makes Jest at least two times slower._
Whether to use the cache. Defaults to true. Disable the cache using `--no-cache`.

:::caution

The cache should only be disabled if you are experiencing caching related problems. On average, disabling the cache makes Jest at least two times slower.

:::

If you want to inspect the cache, use `--showConfig` and look at the `cacheDirectory` value. If you need to clear the cache, use `--clearCache`.

Expand All @@ -136,7 +146,13 @@ When this option is provided, Jest will assume it is running in a CI environment

### `--clearCache`

Deletes the Jest cache directory and then exits without running tests. Will delete `cacheDirectory` if the option is passed, or Jest's default cache directory. The default cache directory can be found by calling `jest --showConfig`. _Note: clearing the cache will reduce performance._
Deletes the Jest cache directory and then exits without running tests. Will delete `cacheDirectory` if the option is passed, or Jest's default cache directory. The default cache directory can be found by calling `jest --showConfig`.

:::caution

Clearing the cache will reduce performance.

:::

### `--clearMocks`

Expand Down Expand Up @@ -204,7 +220,13 @@ Find and run the tests that cover a space separated list of source files that we

### `--forceExit`

Force Jest to exit after all tests have completed running. This is useful when resources set up by test code cannot be adequately cleaned up. _Note: This feature is an escape-hatch. If Jest doesn't exit at the end of a test run, it means external resources are still being held on to or timers are still pending in your code. It is advised to tear down external resources after each test to make sure Jest can shut down cleanly. You can use `--detectOpenHandles` to help track it down._
Force Jest to exit after all tests have completed running. This is useful when resources set up by test code cannot be adequately cleaned up.

:::caution

This feature is an escape-hatch. If Jest doesn't exit at the end of a test run, it means external resources are still being held on to or timers are still pending in your code. It is advised to tear down external resources after each test to make sure Jest can shut down cleanly. You can use `--detectOpenHandles` to help track it down.

:::

### `--help`

Expand All @@ -228,7 +250,11 @@ test('some test', () => {
});
```

_Note: This option is only supported using the default `jest-circus` test runner._
:::note

This option is only supported using the default `jest-circus` test runner.

:::

### `--json`

Expand Down Expand Up @@ -278,7 +304,7 @@ Allows the test suite to pass when no files are found.

### `--projects <path1> ... <pathN>`

Run tests from one or more projects, found in the specified paths; also takes path globs. This option is the CLI equivalent of the [`projects`](configuration#projects-arraystring--projectconfig) configuration option. :::note
Run tests from one or more projects, found in the specified paths; also takes path globs. This option is the CLI equivalent of the [`projects`](configuration#projects-arraystring--projectconfig) configuration option.

:::note

Expand Down Expand Up @@ -312,7 +338,11 @@ Alias: `-i`. Run all tests serially in the current process, rather than creating

Run only the tests that were specified with their exact paths.

_Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_
:::tip

The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files.

:::

### `--selectProjects <project1> ... <projectN>`

Expand Down Expand Up @@ -357,9 +387,13 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

Note: The regex is matched against the full name, which is a combination of the test name and all its surrounding describe blocks.
:::tip

The regex is matched against the full name, which is a combination of the test name and all its surrounding describe blocks.

:::

### `--testPathIgnorePatterns=<regex>|[array]`

Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-28.x/CLI.md
Expand Up @@ -423,7 +423,7 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

:::tip

Expand Down
4 changes: 2 additions & 2 deletions website/versioned_docs/version-29.0/CLI.md
Expand Up @@ -417,7 +417,7 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

:::tip

Expand Down Expand Up @@ -473,7 +473,7 @@ Watch files for changes and rerun all tests when something changes. If you want

Use `--watchAll=false` to explicitly disable the watch mode.

:::note
:::tip

In most CI environments, this is automatically handled for you.

Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.1/CLI.md
Expand Up @@ -417,7 +417,7 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

:::tip

Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.2/CLI.md
Expand Up @@ -437,7 +437,7 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

:::tip

Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.3/CLI.md
Expand Up @@ -437,7 +437,7 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

:::tip

Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.4/CLI.md
Expand Up @@ -437,7 +437,7 @@ The glob patterns Jest uses to detect test files. Please refer to the [`testMatc

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.
Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `'GET /api/posts with auth'`, then you can use `jest -t=auth`.

:::tip

Expand Down

0 comments on commit f9f7d79

Please sign in to comment.