Skip to content

Commit

Permalink
docs(cli): updated documentation for --runTestsByPath command (#14004)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpizzinidev committed Mar 22, 2023
1 parent 04f11d8 commit b38d7d3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,8 @@

### Chore & Maintenance

- `[docs]` Updated documentation for the `--runTestsByPath` CLI command ([#14004](https://github.com/facebook/jest/pull/14004))

### Performance

## 29.5.0
Expand Down
34 changes: 33 additions & 1 deletion docs/CLI.md
Expand Up @@ -372,7 +372,39 @@ Alias: `-i`. Run all tests serially in the current process, rather than creating

### `--runTestsByPath`

Run only the tests that were specified with their exact paths.
Run only the tests that were specified with their exact paths. This avoids converting them into a regular expression and matching it against every single file.

For example, given the following file structure:

```bash
__tests__
└── t1.test.js # test
└── t2.test.js # test
```

When ran with a pattern, no test is found:

```bash
jest --runTestsByPath __tests__/t
```

Output:

```bash
No tests found
```

However, passing an exact path will execute only the given test:

```bash
jest --runTestsByPath __tests__/t1.test.js
```

Output:

```bash
PASS __tests__/t1.test.js
```

:::tip

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/runTestsByPath.test.ts
Expand Up @@ -28,7 +28,7 @@ test('runs tests by exact path', () => {
expect(run1.stderr).toMatch('PASS __tests__/t1.test.js');
expect(run1.stderr).not.toMatch('PASS __tests__/t2.test.js');

// When running with thte flag and a pattern, no test is found.
// When running with the flag and a pattern, no test is found.
const run2 = runJest(DIR, ['--runTestsByPath', '__tests__/t']);
expect(run2.stdout).toMatch(/no tests found/i);

Expand Down

0 comments on commit b38d7d3

Please sign in to comment.