Skip to content

Commit

Permalink
Return exit code 1 if coverage threshold requirements are not met (je…
Browse files Browse the repository at this point in the history
…stjs#1974)

* determine if a run is successful after onRunComplete

* Update TestRunner.js
  • Loading branch information
lazywithclass authored and nickpresta committed Nov 15, 2016
1 parent 6037103 commit 330c270
Showing 1 changed file with 17 additions and 18 deletions.
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

0 comments on commit 330c270

Please sign in to comment.