Skip to content

Commit 68dca2a

Browse files
Fix testPathPatterns when config is in subdirectory (#14934)
1 parent cb15c34 commit 68dca2a

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

+405
-145
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
6565
- `[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589))
6666
- `[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
67-
- `[jest-util]` Add missing dependency on `jest-regex-util` ([#15030](https://github.com/jestjs/jest/pull/15030))
6867
- `[pretty-format]` [**BREAKING**] Print `ArrayBuffer` and `DataView` correctly ([#14290](https://github.com/jestjs/jest/pull/14290))
6968
- `[jest-cli]` When specifying paths on the command line, only match against the relative paths of the test files ([#12519](https://github.com/jestjs/jest/pull/12519))
7069
- [**BREAKING**] Changes `testPathPattern` configuration option to `testPathPatterns`, which now takes a list of patterns instead of the regex.
7170
- [**BREAKING**] `--testPathPattern` is now `--testPathPatterns`
71+
- [**BREAKING**] Specifying `testPathPatterns` when programmatically calling `watch` must be specified as `new TestPathPatterns(patterns)`, where `TestPathPatterns` can be imported from `@jest/pattern`
7272
- `[jest-reporters, jest-runner]` Unhandled errors without stack get correctly logged to console ([#14619](https://github.com/jestjs/jest/pull/14619))
7373

7474
### Performance

e2e/__tests__/executeTestsOnceInMpr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test('Tests are executed only once even in an MPR', () => {
4646
});
4747
/* eslint-enable sort-keys */
4848

49-
const {stderr, exitCode} = runJest(DIR, ['foo/folder/my-test-bar.js']);
49+
const {stderr, exitCode} = runJest(DIR, ['my-test-bar.js']);
5050

5151
expect(exitCode).toBe(0);
5252

e2e/__tests__/globalSetup.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ test('should not call a globalSetup of a project if there are no tests to run fr
109109

110110
const result = runWithJson(e2eDir, [
111111
`--config=${configPath}`,
112-
'--testPathPatterns=project-1',
112+
'--testPathPatterns=setup1',
113113
]);
114114

115115
expect(result.exitCode).toBe(0);

e2e/__tests__/globalTeardown.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ test('should not call a globalTeardown of a project if there are no tests to run
9393

9494
const result = runWithJson('global-teardown', [
9595
`--config=${configPath}`,
96-
'--testPathPatterns=project-1',
96+
'--testPathPatterns=teardown1',
9797
]);
9898

9999
expect(result.exitCode).toBe(0);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
import {json} from '../runJest';
8+
9+
it('works when specifying --testPathPatterns when config is in subdir', () => {
10+
const {
11+
json: {numTotalTests},
12+
} = json('test-path-patterns-subprojects', [
13+
'--config=config/jest.config.js',
14+
'--testPathPatterns=testA',
15+
]);
16+
expect(numTotalTests).toBe(1);
17+
});

e2e/global-setup/setupWithConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
*/
77

88
module.exports = function (globalConfig, projectConfig) {
9-
console.log(globalConfig.testPathPatterns);
9+
console.log(globalConfig.testPathPatterns.patterns);
1010
console.log(projectConfig.cache);
1111
};

e2e/global-setup/setupWithDefaultExport.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
*/
77

88
export default function (globalConfig, projectConfig): void {
9-
console.log(globalConfig.testPathPatterns);
9+
console.log(globalConfig.testPathPatterns.patterns);
1010
console.log(projectConfig.cache);
1111
}

0 commit comments

Comments
 (0)