( testRunData: TestRunData, globalConfig: Config.GlobalConfig, willExitWith0: boolean, )
| 11 | import type {TestRunData} from './types'; |
| 12 | |
| 13 | export 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 | } |
no test coverage detected