Skip to content

Commit

Permalink
Replace remaining usages of globalConfig.testPathPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 committed Sep 22, 2023
1 parent e347e72 commit 6713c2c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion e2e/__tests__/multiProjectRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ test('"No tests found" message for projects', () => {
'project1',
'project2',
]);
expect(verboseOutput).toContain('Pattern: xyz321 - 0 matches');
expect(verboseOutput).toContain('Pattern: /xyz321/i - 0 matches');
const {stdout} = runJest(DIR, [
'--no-watchman',
'xyz321',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Object {
Run with \`--passWithNoTests\` to exit with code 0
In <bold>/root/dir</intensity>
0 files checked across 0 projects. Run with \`--verbose\` for more details.
Pattern: <yellow>/path/pattern</color> - 0 matches",
Pattern: <yellow>/\\/path\\/pattern/i</color> - 0 matches",
}
`;
Expand All @@ -47,7 +47,7 @@ Object {
"message": "<bold>No tests found, exiting with code 1</intensity>
Run with \`--passWithNoTests\` to exit with code 0
Pattern: <yellow>/path/pattern</color> - 0 matches",
Pattern: <yellow>/\\/path\\/pattern/i</color> - 0 matches",
}
`;
Expand All @@ -58,6 +58,6 @@ Object {
Run with \`--passWithNoTests\` to exit with code 0
In <bold>/root/dir</intensity>
0 files checked across 0 projects. Run with \`--verbose\` for more details.
Pattern: <yellow>/path/pattern</color> - 0 matches",
Pattern: <yellow>/\\/path\\/pattern/i</color> - 0 matches",
}
`;
5 changes: 3 additions & 2 deletions packages/jest-core/src/getNoTestFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

export default function getNoTestFound(
Expand All @@ -26,8 +26,9 @@ export default function getNoTestFound(
.map(p => `"${p}"`)
.join(', ')}`;
} else {
const testPathPatterns = new TestPathPatterns(globalConfig);
dataMessage = `Pattern: ${chalk.yellow(
globalConfig.testPathPattern,
testPathPatterns.toPretty(),
)} - 0 matches`;
}

Expand Down
5 changes: 3 additions & 2 deletions packages/jest-core/src/getNoTestFoundVerbose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

export default function getNoTestFoundVerbose(
Expand Down Expand Up @@ -56,8 +56,9 @@ export default function getNoTestFoundVerbose(
.map(p => `"${p}"`)
.join(', ')}`;
} else {
const testPathPatterns = new TestPathPatterns(globalConfig);
dataMessage = `Pattern: ${chalk.yellow(
globalConfig.testPathPattern,
testPathPatterns.toPretty(),
)} - 0 matches`;
}

Expand Down
11 changes: 6 additions & 5 deletions packages/jest-core/src/lib/activeFiltersMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

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

const activeFilters = (globalConfig: Config.GlobalConfig): string => {
const {testNamePattern, testPathPattern} = globalConfig;
if (testNamePattern || testPathPattern) {
const {testNamePattern} = globalConfig;
const testPathPatterns = new TestPathPatterns(globalConfig);
if (testNamePattern || testPathPatterns.isSet()) {
const filters = [
testPathPattern
? chalk.dim('filename ') + chalk.yellow(`/${testPathPattern}/`)
testPathPatterns.isSet()
? chalk.dim('filename ') + chalk.yellow(testPathPatterns.toPretty())
: null,
testNamePattern
? chalk.dim('test name ') + chalk.yellow(`/${testNamePattern}/`)
Expand Down
5 changes: 3 additions & 2 deletions packages/jest-core/src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,11 @@ const usage = (
watchPlugins: Array<WatchPlugin>,
delimiter = '\n',
) => {
const testPathPatterns = new TestPathPatterns(globalConfig);
const messages = [
activeFilters(globalConfig),

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

(globalConfig.watchAll ||
globalConfig.testPathPattern ||
testPathPatterns.isSet() ||
globalConfig.testNamePattern) &&
!globalConfig.noSCM
? `${chalk.dim(' \u203A Press ')}o${chalk.dim(
Expand Down

0 comments on commit 6713c2c

Please sign in to comment.