Skip to content

Commit 6713c2c

Browse files
Replace remaining usages of globalConfig.testPathPattern
1 parent e347e72 commit 6713c2c

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

e2e/__tests__/multiProjectRunner.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ test('"No tests found" message for projects', () => {
155155
'project1',
156156
'project2',
157157
]);
158-
expect(verboseOutput).toContain('Pattern: xyz321 - 0 matches');
158+
expect(verboseOutput).toContain('Pattern: /xyz321/i - 0 matches');
159159
const {stdout} = runJest(DIR, [
160160
'--no-watchman',
161161
'xyz321',

packages/jest-core/src/__tests__/__snapshots__/getNoTestsFoundMessage.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Object {
2323
Run with \`--passWithNoTests\` to exit with code 0
2424
In <bold>/root/dir</intensity>
2525
0 files checked across 0 projects. Run with \`--verbose\` for more details.
26-
Pattern: <yellow>/path/pattern</color> - 0 matches",
26+
Pattern: <yellow>/\\/path\\/pattern/i</color> - 0 matches",
2727
}
2828
`;
2929
@@ -47,7 +47,7 @@ Object {
4747
"message": "<bold>No tests found, exiting with code 1</intensity>
4848
Run with \`--passWithNoTests\` to exit with code 0
4949
50-
Pattern: <yellow>/path/pattern</color> - 0 matches",
50+
Pattern: <yellow>/\\/path\\/pattern/i</color> - 0 matches",
5151
}
5252
`;
5353
@@ -58,6 +58,6 @@ Object {
5858
Run with \`--passWithNoTests\` to exit with code 0
5959
In <bold>/root/dir</intensity>
6060
0 files checked across 0 projects. Run with \`--verbose\` for more details.
61-
Pattern: <yellow>/path/pattern</color> - 0 matches",
61+
Pattern: <yellow>/\\/path\\/pattern/i</color> - 0 matches",
6262
}
6363
`;

packages/jest-core/src/getNoTestFound.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import chalk = require('chalk');
99
import type {Config} from '@jest/types';
10-
import {pluralize} from 'jest-util';
10+
import {TestPathPatterns, pluralize} from 'jest-util';
1111
import type {TestRunData} from './types';
1212

1313
export default function getNoTestFound(
@@ -26,8 +26,9 @@ export default function getNoTestFound(
2626
.map(p => `"${p}"`)
2727
.join(', ')}`;
2828
} else {
29+
const testPathPatterns = new TestPathPatterns(globalConfig);
2930
dataMessage = `Pattern: ${chalk.yellow(
30-
globalConfig.testPathPattern,
31+
testPathPatterns.toPretty(),
3132
)} - 0 matches`;
3233
}
3334

packages/jest-core/src/getNoTestFoundVerbose.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import chalk = require('chalk');
99
import type {Config} from '@jest/types';
10-
import {pluralize} from 'jest-util';
10+
import {TestPathPatterns, pluralize} from 'jest-util';
1111
import type {Stats, TestRunData} from './types';
1212

1313
export default function getNoTestFoundVerbose(
@@ -56,8 +56,9 @@ export default function getNoTestFoundVerbose(
5656
.map(p => `"${p}"`)
5757
.join(', ')}`;
5858
} else {
59+
const testPathPatterns = new TestPathPatterns(globalConfig);
5960
dataMessage = `Pattern: ${chalk.yellow(
60-
globalConfig.testPathPattern,
61+
testPathPatterns.toPretty(),
6162
)} - 0 matches`;
6263
}
6364

packages/jest-core/src/lib/activeFiltersMessage.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
import chalk = require('chalk');
99
import type {Config} from '@jest/types';
10-
import {isNonNullable} from 'jest-util';
10+
import {TestPathPatterns, isNonNullable} from 'jest-util';
1111

1212
const activeFilters = (globalConfig: Config.GlobalConfig): string => {
13-
const {testNamePattern, testPathPattern} = globalConfig;
14-
if (testNamePattern || testPathPattern) {
13+
const {testNamePattern} = globalConfig;
14+
const testPathPatterns = new TestPathPatterns(globalConfig);
15+
if (testNamePattern || testPathPatterns.isSet()) {
1516
const filters = [
16-
testPathPattern
17-
? chalk.dim('filename ') + chalk.yellow(`/${testPathPattern}/`)
17+
testPathPatterns.isSet()
18+
? chalk.dim('filename ') + chalk.yellow(testPathPatterns.toPretty())
1819
: null,
1920
testNamePattern
2021
? chalk.dim('test name ') + chalk.yellow(`/${testNamePattern}/`)

packages/jest-core/src/watch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,11 @@ const usage = (
537537
watchPlugins: Array<WatchPlugin>,
538538
delimiter = '\n',
539539
) => {
540+
const testPathPatterns = new TestPathPatterns(globalConfig);
540541
const messages = [
541542
activeFilters(globalConfig),
542543

543-
globalConfig.testPathPattern || globalConfig.testNamePattern
544+
testPathPatterns.isSet() || globalConfig.testNamePattern
544545
? `${chalk.dim(' \u203A Press ')}c${chalk.dim(' to clear filters.')}`
545546
: null,
546547
`\n${chalk.bold('Watch Usage')}`,
@@ -558,7 +559,7 @@ const usage = (
558559
)}`,
559560

560561
(globalConfig.watchAll ||
561-
globalConfig.testPathPattern ||
562+
testPathPatterns.isSet() ||
562563
globalConfig.testNamePattern) &&
563564
!globalConfig.noSCM
564565
? `${chalk.dim(' \u203A Press ')}o${chalk.dim(

0 commit comments

Comments
 (0)