diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c27107f5a21..ced77a5d4a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,8 @@ ### Fixes +* `[jest-cli]` Remove the notifier actions in case of failure when not in watch + mode. ([#5861](https://github.com/facebook/jest/pull/5861)) * `[jest-mock]` Extend .toHaveBeenCalled return message with outcome ([#5951](https://github.com/facebook/jest/pull/5951)) * `[jest-runner]` Assign `process.env.JEST_WORKER_ID="1"` when in runInBand mode diff --git a/packages/jest-cli/src/reporters/notify_reporter.js b/packages/jest-cli/src/reporters/notify_reporter.js index 6603c48c31a2..91d7df636c83 100644 --- a/packages/jest-cli/src/reporters/notify_reporter.js +++ b/packages/jest-cli/src/reporters/notify_reporter.js @@ -79,30 +79,41 @@ export default class NotifyReporter extends BaseReporter { result.numTotalTests, ); + const watchMode = this._globalConfig.watch || this._globalConfig.watchAll; const restartAnswer = 'Run again'; const quitAnswer = 'Exit tests'; - notifier.notify( - { - actions: [restartAnswer, quitAnswer], - closeLabel: 'Close', + + if (!watchMode) { + notifier.notify({ icon, message, title, - }, - (err, _, metadata) => { - if (err || !metadata) { - return; - } - if (metadata.activationValue === quitAnswer) { - exit(0); - return; - } - if (metadata.activationValue === restartAnswer) { - this._startRun(this._globalConfig); - } - }, - ); + }); + } else { + notifier.notify( + { + actions: [restartAnswer, quitAnswer], + closeLabel: 'Close', + icon, + message, + title, + }, + (err, _, metadata) => { + if (err || !metadata) { + return; + } + if (metadata.activationValue === quitAnswer) { + exit(0); + return; + } + if (metadata.activationValue === restartAnswer) { + this._startRun(this._globalConfig); + } + }, + ); + } } + this._context.previousSuccess = success; this._context.firstRun = false; }