Skip to content

Commit e347e72

Browse files
Update docs + tests to use globalConfig.testPathPatterns
1 parent 518c357 commit e347e72

File tree

11 files changed

+18
-24
lines changed

11 files changed

+18
-24
lines changed

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#--testpathpatternregex)
176176
- [`updateSnapshot`](cli#--updatesnapshot)
177177
- [`verbose`](configuration#verbose-boolean)
178178

e2e/__tests__/globalSetup.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,13 @@ test('jest throws an error when globalSetup does not export a function', () => {
8383
test('globalSetup function gets global config object and project config as parameters', () => {
8484
const setupPath = path.resolve(e2eDir, 'setupWithConfig.js');
8585

86-
const testPathPattern = 'pass';
87-
8886
const result = runJest(e2eDir, [
8987
`--globalSetup=${setupPath}`,
90-
`--testPathPattern=${testPathPattern}`,
88+
'--testPathPattern=pass',
9189
'--cache=true',
9290
]);
9391

94-
expect(result.stdout).toBe(`${testPathPattern}\ntrue`);
92+
expect(result.stdout).toBe("[ 'pass' ]\ntrue");
9593
});
9694

9795
test('should call globalSetup function of multiple projects', () => {
@@ -140,15 +138,13 @@ test('should not call any globalSetup if there are no tests to run', () => {
140138
test('globalSetup works with default export', () => {
141139
const setupPath = path.resolve(e2eDir, 'setupWithDefaultExport.js');
142140

143-
const testPathPattern = 'pass';
144-
145141
const result = runJest(e2eDir, [
146142
`--globalSetup=${setupPath}`,
147-
`--testPathPattern=${testPathPattern}`,
143+
'--testPathPattern=pass',
148144
'--cache=true',
149145
]);
150146

151-
expect(result.stdout).toBe(`${testPathPattern}\ntrue`);
147+
expect(result.stdout).toBe("[ 'pass' ]\ntrue");
152148
});
153149

154150
test('globalSetup throws with named export', () => {

e2e/__tests__/globalTeardown.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ test('jest throws an error when globalTeardown does not export a function', () =
6767
test('globalSetup function gets global config object and project config as parameters', () => {
6868
const teardownPath = path.resolve(e2eDir, 'teardownWithConfig.js');
6969

70-
const testPathPattern = 'pass';
71-
7270
const result = runJest(e2eDir, [
7371
`--globalTeardown=${teardownPath}`,
74-
`--testPathPattern=${testPathPattern}`,
72+
'--testPathPattern=pass',
7573
'--cache=true',
7674
]);
7775

78-
expect(result.stdout).toBe(`${testPathPattern}\ntrue`);
76+
expect(result.stdout).toBe("[ 'pass' ]\ntrue");
7977
});
8078

8179
test('should call globalTeardown function of multiple projects', () => {
@@ -112,11 +110,11 @@ test('globalTeardown works with default export', () => {
112110

113111
const result = runJest(e2eDir, [
114112
`--globalTeardown=${teardownPath}`,
115-
`--testPathPattern=${testPathPattern}`,
113+
'--testPathPattern=pass',
116114
'--cache=true',
117115
]);
118116

119-
expect(result.stdout).toBe(`${testPathPattern}\ntrue`);
117+
expect(result.stdout).toBe("[ 'pass' ]\ntrue");
120118
});
121119

122120
test('globalTeardown throws with named export', () => {

e2e/global-setup/invalidSetupWithNamedExport.js

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

88
function invalidSetupWithNamedExport(jestConfig): void {
9-
console.log(jestConfig.testPathPattern);
9+
console.log(jestConfig.testPathPatterns);
1010
}
1111

1212
export {invalidSetupWithNamedExport};

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.testPathPattern);
9+
console.log(globalConfig.testPathPatterns);
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.testPathPattern);
9+
console.log(globalConfig.testPathPatterns);
1010
console.log(projectConfig.cache);
1111
}

e2e/global-teardown/invalidTeardownWithNamedExport.js

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

88
function invalidTeardownWithNamedExport(jestConfig): void {
9-
console.log(jestConfig.testPathPattern);
9+
console.log(jestConfig.testPathPatterns);
1010
}
1111

1212
export {invalidTeardownWithNamedExport};

e2e/global-teardown/teardownWithConfig.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.testPathPattern);
9+
console.log(globalConfig.testPathPatterns);
1010
console.log(projectConfig.cache);
1111
};

e2e/global-teardown/teardownWithDefaultExport.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.testPathPattern);
9+
console.log(globalConfig.testPathPatterns);
1010
console.log(projectConfig.cache);
1111
}

0 commit comments

Comments
 (0)