MCPcopy
hub / github.com/jestjs/jest / getNoTestFound

Function getNoTestFound

packages/jest-core/src/getNoTestFound.ts:13–61  ·  view source on GitHub ↗
(
  testRunData: TestRunData,
  globalConfig: Config.GlobalConfig,
  willExitWith0: boolean,
)

Source from the content-addressed store, hash-verified

11import type {TestRunData} from './types';
12
13export default function getNoTestFound(
14 testRunData: TestRunData,
15 globalConfig: Config.GlobalConfig,
16 willExitWith0: boolean,
17): string {
18 const testFiles = testRunData.reduce(
19 (current, testRun) => current + (testRun.matches.total || 0),
20 0,
21 );
22 let dataMessage;
23
24 if (globalConfig.runTestsByPath) {
25 dataMessage = `Files: ${globalConfig.nonFlagArgs
26 .map(p => `"${p}"`)
27 .join(', ')}`;
28 } else {
29 dataMessage = `Pattern: ${chalk.yellow(
30 globalConfig.testPathPatterns.toPretty(),
31 )} - 0 matches`;
32 }
33
34 if (willExitWith0) {
35 return (
36 `${chalk.bold('No tests found, exiting with code 0')}\n` +
37 `In ${chalk.bold(globalConfig.rootDir)}` +
38 '\n' +
39 ` ${pluralize('file', testFiles, 's')} checked across ${pluralize(
40 'project',
41 testRunData.length,
42 's',
43 )}. Run with \`--verbose\` for more details.` +
44 `\n${dataMessage}`
45 );
46 }
47
48 return (
49 `${chalk.bold('No tests found, exiting with code 1')}\n` +
50 'Run with `--passWithNoTests` to exit with code 0' +
51 '\n' +
52 `In ${chalk.bold(globalConfig.rootDir)}` +
53 '\n' +
54 ` ${pluralize('file', testFiles, 's')} checked across ${pluralize(
55 'project',
56 testRunData.length,
57 's',
58 )}. Run with \`--verbose\` for more details.` +
59 `\n${dataMessage}`
60 );
61}

Callers 1

getNoTestsFoundMessageFunction · 0.85

Calls 2

pluralizeFunction · 0.90
toPrettyMethod · 0.65

Tested by

no test coverage detected