Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change --passWithNoTests message to match exit code #8193

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions packages/jest-core/src/getNoTestFound.ts
Expand Up @@ -30,11 +30,7 @@ export default function getNoTestFound(
)} - 0 matches`;
}

return (
chalk.bold('No tests found, exiting with code 1') +
'\n' +
'Run with `--passWithNoTests` to exit with code 0' +
'\n' +
const fixedMessage =
`In ${chalk.bold(globalConfig.rootDir)}` +
'\n' +
` ${pluralize('file', testFiles, 's')} checked across ${pluralize(
Expand All @@ -43,6 +39,19 @@ export default function getNoTestFound(
's',
)}. Run with \`--verbose\` for more details.` +
'\n' +
dataMessage
dataMessage;

if (globalConfig.passWithNoTests) {
return (
chalk.bold('No tests found, exiting with code 0') + '\n' + fixedMessage
);
}

return (
chalk.bold('No tests found, exiting with code 1') +
'\n' +
'Run with `--passWithNoTests` to exit with code 0' +
'\n' +
fixedMessage
);
}
10 changes: 10 additions & 0 deletions packages/jest-core/src/getNoTestFoundVerbose.ts
Expand Up @@ -52,6 +52,16 @@ export default function getNoTestFoundVerbose(
)} - 0 matches`;
}

if (globalConfig.passWithNoTests) {
return (
chalk.bold('No tests found, exiting with code 0') +
'\n' +
individualResults.join('\n') +
'\n' +
dataMessage
);
}

return (
chalk.bold('No tests found, exiting with code 1') +
'\n' +
Expand Down