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

Return exit code 1 if coverage threshold requirements are not met #1974

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions packages/jest-cli/src/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ class TestRunner {
)
);

const finalizeResults = () => {
// Update snapshot state.
const updateSnapshotState = () => {
const status =
snapshot.cleanup(this._hasteContext.hasteFS, config.updateSnapshot);
aggregatedResults.snapshot.filesRemoved += status.filesRemoved;
Expand All @@ -238,21 +237,6 @@ class TestRunner {
aggregatedResults.snapshot.filesRemoved
)
);

aggregatedResults.wasInterrupted = watcher.isInterrupted();

// Check if the test run was successful or not.
const anyTestFailures = !(
aggregatedResults.numFailedTests === 0 &&
aggregatedResults.numRuntimeErrorTestSuites === 0
);
const anyReporterErrors = this._dispatcher.hasErrors();

aggregatedResults.success = !(
anyTestFailures ||
aggregatedResults.snapshot.failure ||
anyReporterErrors
);
};

const runInBand = shouldRunInBand();
Expand All @@ -278,8 +262,23 @@ class TestRunner {
}
})
.then(() => {
finalizeResults();
updateSnapshotState();
aggregatedResults.wasInterrupted = watcher.isInterrupted();

this._dispatcher.onRunComplete(config, aggregatedResults);

const anyTestFailures = !(
aggregatedResults.numFailedTests === 0 &&
aggregatedResults.numRuntimeErrorTestSuites === 0
);
const anyReporterErrors = this._dispatcher.hasErrors();

aggregatedResults.success = !(
anyTestFailures ||
aggregatedResults.snapshot.failure ||
anyReporterErrors
);

this._cacheTestResults(aggregatedResults);
return aggregatedResults;
});
Expand Down