Skip to content

Commit 41133b5

Browse files
Only match relative paths when specifying paths (#12519)
Co-authored-by: Brandon Chinn <brandonchinn178@gmail.com>
1 parent 46285d8 commit 41133b5

File tree

65 files changed

+488
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+488
-330
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
- `[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589))
2626
- `[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
2727
- `[pretty-format]` [**BREAKING**] Print `ArrayBuffer` and `DataView` correctly ([#14290](https://github.com/facebook/jest/pull/14290))
28+
- `[jest-cli]` When specifying paths on the command line, only match against the relative paths of the test files ([#12519](https://github.com/facebook/jest/pull/12519))
29+
- [**BREAKING**] Changes `testPathPattern` configuration option to `testPathPatterns`, which now takes a list of patterns instead of the regex.
30+
- [**BREAKING**] `--testPathPattern` is now `--testPathPatterns`
2831

2932
### Performance
3033

docs/CLI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,11 @@ The regex is matched against the full name, which is a combination of the test n
481481

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

484-
A single or array of regexp pattern strings that are tested against all tests paths before executing the test. Contrary to `--testPathPattern`, it will only run those tests with a path that does not match with the provided regexp expressions.
484+
A single or array of regexp pattern strings that are tested against all tests paths before executing the test. Contrary to `--testPathPatterns`, it will only run those tests with a path that does not match with the provided regexp expressions.
485485

486486
To pass as an array use escaped parentheses and space delimited regexps such as `\(/node_modules/ /tests/e2e/\)`. Alternatively, you can omit parentheses by combining regexps into a single regexp like `/node_modules/|/tests/e2e/`. These two examples are equivalent.
487487

488-
### `--testPathPattern=<regex>`
488+
### `--testPathPatterns=<regex>`
489489

490490
A regexp pattern string that is matched against all tests paths before executing the test. On Windows, you will need to use `/` as a path separator or escape `\` as `\\`.
491491

docs/Configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ While code transformation is applied to the linked setup-file, Jest will **not**
787787

788788
```js title="setup.js"
789789
module.exports = async function (globalConfig, projectConfig) {
790-
console.log(globalConfig.testPathPattern);
790+
console.log(globalConfig.testPathPatterns);
791791
console.log(projectConfig.cache);
792792

793793
// Set reference to mongod in order to close the server during teardown.
@@ -797,7 +797,7 @@ module.exports = async function (globalConfig, projectConfig) {
797797

798798
```js title="teardown.js"
799799
module.exports = async function (globalConfig, projectConfig) {
800-
console.log(globalConfig.testPathPattern);
800+
console.log(globalConfig.testPathPatterns);
801801
console.log(projectConfig.cache);
802802

803803
await globalThis.__MONGOD__.stop();

docs/WatchPlugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ For stability and safety reasons, only part of the global configuration keys can
172172
- [`onlyFailures`](configuration#onlyfailures-boolean)
173173
- [`reporters`](configuration#reporters-arraymodulename--modulename-options)
174174
- [`testNamePattern`](cli#--testnamepatternregex)
175-
- [`testPathPattern`](cli#--testpathpatternregex)
175+
- [`testPathPatterns`](cli#--testpathpatternsregex)
176176
- [`updateSnapshot`](cli#--updatesnapshot)
177177
- [`verbose`](configuration#verbose-boolean)
178178

e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ exports[`CLI accepts exact file names if matchers matched 2`] = `
1313
Tests: 1 passed, 1 total
1414
Snapshots: 0 total
1515
Time: <<REPLACED>>
16-
Ran all test suites matching /.\\/foo\\/bar.spec.js/i."
16+
Ran all test suites matching ./foo/bar.spec.js."
1717
`;

e2e/__tests__/__snapshots__/customReporters.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ exports[`Custom Reporters Integration default reporters enabled 2`] = `
8282
Tests: 1 passed, 1 total
8383
Snapshots: 0 total
8484
Time: <<REPLACED>>
85-
Ran all test suites matching /add.test.js/i."
85+
Ran all test suites matching add.test.js."
8686
`;
8787
8888
exports[`Custom Reporters Integration default reporters enabled 3`] = `

e2e/__tests__/__snapshots__/emptyDescribeWithHooks.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Object {
77
Tests: 1 skipped, 1 total
88
Snapshots: 0 total
99
Time: <<REPLACED>>
10-
Ran all test suites matching /hookInDescribeWithSkippedTest.test.js/i.",
10+
Ran all test suites matching hookInDescribeWithSkippedTest.test.js.",
1111
}
1212
`;
1313

@@ -34,7 +34,7 @@ Object {
3434
Tests: 1 passed, 1 total
3535
Snapshots: 0 total
3636
Time: <<REPLACED>>
37-
Ran all test suites matching /hookInEmptyDescribe.test.js/i.",
37+
Ran all test suites matching hookInEmptyDescribe.test.js.",
3838
}
3939
`;
4040
@@ -61,7 +61,7 @@ Object {
6161
Tests: 1 passed, 1 total
6262
Snapshots: 0 total
6363
Time: <<REPLACED>>
64-
Ran all test suites matching /hookInEmptyNestedDescribe.test.js/i.",
64+
Ran all test suites matching hookInEmptyNestedDescribe.test.js.",
6565
}
6666
`;
6767
@@ -133,6 +133,6 @@ Object {
133133
Tests: 1 passed, 1 total
134134
Snapshots: 0 total
135135
Time: <<REPLACED>>
136-
Ran all test suites matching /multipleHooksInEmptyDescribe.test.js/i.",
136+
Ran all test suites matching multipleHooksInEmptyDescribe.test.js.",
137137
}
138138
`;

e2e/__tests__/__snapshots__/findRelatedFiles.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`--findRelatedTests flag coverage configuration is applied correctly 1`]
55
Tests: 1 passed, 1 total
66
Snapshots: 0 total
77
Time: <<REPLACED>>
8-
Ran all test suites related to files matching /a.js|b.js/i."
8+
Ran all test suites related to files matching a.js|b.js."
99
`;
1010
1111
exports[`--findRelatedTests flag coverage configuration is applied correctly 2`] = `
@@ -50,7 +50,7 @@ exports[`--findRelatedTests flag generates coverage report for filename 4`] = `
5050
Tests: 1 passed, 1 total
5151
Snapshots: 0 total
5252
Time: <<REPLACED>>
53-
Ran all test suites related to files matching /a.js/i."
53+
Ran all test suites related to files matching a.js."
5454
`;
5555
5656
exports[`--findRelatedTests flag generates coverage report for filename 5`] = `

e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,61 @@ exports[`does not enforce import assertions 1`] = `
55
Tests: 2 passed, 2 total
66
Snapshots: 0 total
77
Time: <<REPLACED>>
8-
Ran all test suites matching /native-esm-missing-import-assertions.test.js/i."
8+
Ran all test suites matching native-esm-missing-import-assertions.test.js."
99
`;
1010
1111
exports[`on node >=16.11.0 support re-exports from CJS of dual packages 1`] = `
1212
"Test Suites: 1 passed, 1 total
1313
Tests: 1 passed, 1 total
1414
Snapshots: 0 total
1515
Time: <<REPLACED>>
16-
Ran all test suites matching /native-esm-deep-cjs-reexport.test.js/i."
16+
Ran all test suites matching native-esm-deep-cjs-reexport.test.js."
1717
`;
1818
1919
exports[`on node >=16.12.0 supports import assertions 1`] = `
2020
"Test Suites: 1 passed, 1 total
2121
Tests: 2 passed, 2 total
2222
Snapshots: 0 total
2323
Time: <<REPLACED>>
24-
Ran all test suites matching /native-esm-import-assertions.test.js/i."
24+
Ran all test suites matching native-esm-import-assertions.test.js."
2525
`;
2626
2727
exports[`properly handle re-exported native modules in ESM via CJS 1`] = `
2828
"Test Suites: 1 passed, 1 total
2929
Tests: 1 passed, 1 total
3030
Snapshots: 0 total
3131
Time: <<REPLACED>>
32-
Ran all test suites matching /native-esm-native-module.test.js/i."
32+
Ran all test suites matching native-esm-native-module.test.js."
3333
`;
3434
3535
exports[`runs WebAssembly (Wasm) test with native ESM 1`] = `
3636
"Test Suites: 1 passed, 1 total
3737
Tests: 6 passed, 6 total
3838
Snapshots: 0 total
3939
Time: <<REPLACED>>
40-
Ran all test suites matching /native-esm-wasm.test.js/i."
40+
Ran all test suites matching native-esm-wasm.test.js."
4141
`;
4242
4343
exports[`runs test with native ESM 1`] = `
4444
"Test Suites: 1 passed, 1 total
4545
Tests: 33 passed, 33 total
4646
Snapshots: 0 total
4747
Time: <<REPLACED>>
48-
Ran all test suites matching /native-esm.test.js/i."
48+
Ran all test suites matching native-esm.test.js."
4949
`;
5050
5151
exports[`support re-exports from CJS of core module 1`] = `
5252
"Test Suites: 1 passed, 1 total
5353
Tests: 1 passed, 1 total
5454
Snapshots: 0 total
5555
Time: <<REPLACED>>
56-
Ran all test suites matching /native-esm-core-cjs-reexport.test.js/i."
56+
Ran all test suites matching native-esm-core-cjs-reexport.test.js."
5757
`;
5858
5959
exports[`supports top-level await 1`] = `
6060
"Test Suites: 1 passed, 1 total
6161
Tests: 1 passed, 1 total
6262
Snapshots: 0 total
6363
Time: <<REPLACED>>
64-
Ran all test suites matching /native-esm.tla.test.js/i."
64+
Ran all test suites matching native-esm.tla.test.js."
6565
`;

e2e/__tests__/__snapshots__/promiseAsyncHandling.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Object {
2222
Tests: 1 passed, 1 total
2323
Snapshots: 0 total
2424
Time: <<REPLACED>>
25-
Ran all test suites matching /unhandledRejectionAfterAll.test.js/i.",
25+
Ran all test suites matching unhandledRejectionAfterAll.test.js.",
2626
}
2727
`;
2828
@@ -63,7 +63,7 @@ Object {
6363
Tests: 2 failed, 2 total
6464
Snapshots: 0 total
6565
Time: <<REPLACED>>
66-
Ran all test suites matching /unhandledRejectionAfterEach.test.js/i.",
66+
Ran all test suites matching unhandledRejectionAfterEach.test.js.",
6767
}
6868
`;
6969
@@ -89,7 +89,7 @@ Object {
8989
Tests: 1 failed, 1 total
9090
Snapshots: 0 total
9191
Time: <<REPLACED>>
92-
Ran all test suites matching /unhandledRejectionBeforeAll.test.js/i.",
92+
Ran all test suites matching unhandledRejectionBeforeAll.test.js.",
9393
}
9494
`;
9595
@@ -130,7 +130,7 @@ Object {
130130
Tests: 2 failed, 2 total
131131
Snapshots: 0 total
132132
Time: <<REPLACED>>
133-
Ran all test suites matching /unhandledRejectionBeforeEach.test.js/i.",
133+
Ran all test suites matching unhandledRejectionBeforeEach.test.js.",
134134
}
135135
`;
136136
@@ -217,7 +217,7 @@ Object {
217217
Tests: 4 failed, 4 total
218218
Snapshots: 0 total
219219
Time: <<REPLACED>>
220-
Ran all test suites matching /unhandledRejectionTest.test.js/i.",
220+
Ran all test suites matching unhandledRejectionTest.test.js.",
221221
}
222222
`;
223223
@@ -231,6 +231,6 @@ Object {
231231
Tests: 3 passed, 3 total
232232
Snapshots: 0 total
233233
Time: <<REPLACED>>
234-
Ran all test suites matching /rejectionHandled.test.js/i.",
234+
Ran all test suites matching rejectionHandled.test.js.",
235235
}
236236
`;

0 commit comments

Comments
 (0)