From 562ae55bf08ec887c4a1a31e0e246c86be700c39 Mon Sep 17 00:00:00 2001 From: Ran Yitzhaki Date: Fri, 23 Mar 2018 03:10:50 +0300 Subject: [PATCH 1/3] remove notifier actions in case of failure --- .../jest-cli/src/reporters/notify_reporter.js | 29 ++++--------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/packages/jest-cli/src/reporters/notify_reporter.js b/packages/jest-cli/src/reporters/notify_reporter.js index 6603c48c31a2..70ecee8c30ec 100644 --- a/packages/jest-cli/src/reporters/notify_reporter.js +++ b/packages/jest-cli/src/reporters/notify_reporter.js @@ -11,7 +11,6 @@ import type {GlobalConfig} from 'types/Config'; import type {AggregatedResult} from 'types/TestResult'; import type {Context} from 'types/Context'; -import exit from 'exit'; import path from 'path'; import util from 'util'; import notifier from 'node-notifier'; @@ -79,29 +78,11 @@ export default class NotifyReporter extends BaseReporter { result.numTotalTests, ); - const restartAnswer = 'Run again'; - const quitAnswer = 'Exit tests'; - 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); - } - }, - ); + notifier.notify({ + icon, + message, + title, + }); } this._context.previousSuccess = success; this._context.firstRun = false; From b9296bcd97523a1e4abb1c984c71ad18f233f300 Mon Sep 17 00:00:00 2001 From: Ran Yitzhaki Date: Fri, 23 Mar 2018 03:18:17 +0300 Subject: [PATCH 2/3] add to changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 016da2e36835..add8d9056cb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,8 @@ ### Fixes +* `[jest-cli]` Remove the notifier actions in case of failure. + ([#5861](https://github.com/facebook/jest/pull/5861)) * `[jest-runner]` Assign `process.env.JEST_WORKER_ID="1"` when in runInBand mode ([#5860](https://github.com/facebook/jest/pull/5860)) * `[jest-cli]` Add descriptive error message when trying to use From c66be788ac325d8cdd54ac8e185dac84dd40bf11 Mon Sep 17 00:00:00 2001 From: Ran Yitzhaki Date: Fri, 23 Mar 2018 11:50:10 +0300 Subject: [PATCH 3/3] only remove notifications when not in watch mode --- CHANGELOG.md | 4 +- .../jest-cli/src/reporters/notify_reporter.js | 40 ++++++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index add8d9056cb8..8f23f74ea29e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,8 +37,8 @@ ### Fixes -* `[jest-cli]` Remove the notifier actions in case of failure. - ([#5861](https://github.com/facebook/jest/pull/5861)) +* `[jest-cli]` Remove the notifier actions in case of failure when not in watch + mode. ([#5861](https://github.com/facebook/jest/pull/5861)) * `[jest-runner]` Assign `process.env.JEST_WORKER_ID="1"` when in runInBand mode ([#5860](https://github.com/facebook/jest/pull/5860)) * `[jest-cli]` Add descriptive error message when trying to use diff --git a/packages/jest-cli/src/reporters/notify_reporter.js b/packages/jest-cli/src/reporters/notify_reporter.js index 70ecee8c30ec..91d7df636c83 100644 --- a/packages/jest-cli/src/reporters/notify_reporter.js +++ b/packages/jest-cli/src/reporters/notify_reporter.js @@ -11,6 +11,7 @@ import type {GlobalConfig} from 'types/Config'; import type {AggregatedResult} from 'types/TestResult'; import type {Context} from 'types/Context'; +import exit from 'exit'; import path from 'path'; import util from 'util'; import notifier from 'node-notifier'; @@ -78,12 +79,41 @@ export default class NotifyReporter extends BaseReporter { result.numTotalTests, ); - notifier.notify({ - icon, - message, - title, - }); + const watchMode = this._globalConfig.watch || this._globalConfig.watchAll; + const restartAnswer = 'Run again'; + const quitAnswer = 'Exit tests'; + + if (!watchMode) { + notifier.notify({ + icon, + message, + title, + }); + } 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; }