From ac2799dce2c53dc98fe7c20e33e67f05bd689dec Mon Sep 17 00:00:00 2001 From: Ben Ritter Date: Thu, 5 Aug 2021 13:49:02 +0800 Subject: [PATCH 1/4] Change notification to be transient (notify-send) Under GNOME Shell, using `--notify` (especially with `--watch`) floods the notification UI with unnecessary persistent copies of each notification that is raised. See #8773. This change uses [the `notify-send` `hint` option](https://www.npmjs.com/package/node-notifier#usage-notifysend) [`int:transient:1`](https://askubuntu.com/a/1185741) to make the notification transient. --- packages/jest-reporters/src/NotifyReporter.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/jest-reporters/src/NotifyReporter.ts b/packages/jest-reporters/src/NotifyReporter.ts index f24967a00914..043a10493d5a 100644 --- a/packages/jest-reporters/src/NotifyReporter.ts +++ b/packages/jest-reporters/src/NotifyReporter.ts @@ -81,7 +81,13 @@ export default class NotifyReporter extends BaseReporter { result.numPassedTests, )} passed`; - this._notifier.notify({icon, message, timeout: false, title}); + this._notifier.notify({ + hint: 'int:transient:1', + icon, + message, + timeout: false, + title + }); } else if ( testsHaveRun && !success && @@ -109,12 +115,19 @@ export default class NotifyReporter extends BaseReporter { const quitAnswer = 'Exit tests'; if (!watchMode) { - this._notifier.notify({icon, message, timeout: false, title}); + this._notifier.notify({ + hint: 'int:transient:1', + icon, + message, + timeout: false, + title + }); } else { this._notifier.notify( { actions: [restartAnswer, quitAnswer], closeLabel: 'Close', + hint: 'int:transient:1', icon, message, timeout: false, From 6d54f2be438c7e7827a3f15f1c781562e551addc Mon Sep 17 00:00:00 2001 From: Ben Ritter Date: Thu, 5 Aug 2021 14:06:30 +0800 Subject: [PATCH 2/4] Add note about transient notifications --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6b1d88a6a8d..2aca43a79634 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Features +- `[jest-reporters]` Notifications generated by the `--notify` flag are no longer persistent in GNOME Shell. ([#11733](https://github.com/facebook/jest/pull/11733)) + ### Fixes ### Chore & Maintenance From 524c8262b632d8ad408dc569cbde99eeb97ea2de Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 25 Feb 2022 10:25:02 +0100 Subject: [PATCH 3/4] lint --- packages/jest-reporters/src/NotifyReporter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-reporters/src/NotifyReporter.ts b/packages/jest-reporters/src/NotifyReporter.ts index 38bcde3d757e..ac102aa6adab 100644 --- a/packages/jest-reporters/src/NotifyReporter.ts +++ b/packages/jest-reporters/src/NotifyReporter.ts @@ -86,7 +86,7 @@ export default class NotifyReporter extends BaseReporter { icon, message, timeout: false, - title + title, }); } else if ( testsHaveRun && @@ -120,7 +120,7 @@ export default class NotifyReporter extends BaseReporter { icon, message, timeout: false, - title + title, }); } else { this._notifier.notify( From 053550676beb28d297c9266d259358d5b64d4b84 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 25 Feb 2022 10:27:17 +0100 Subject: [PATCH 4/4] ignore ts --- packages/jest-reporters/src/NotifyReporter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/jest-reporters/src/NotifyReporter.ts b/packages/jest-reporters/src/NotifyReporter.ts index ac102aa6adab..f59834586b72 100644 --- a/packages/jest-reporters/src/NotifyReporter.ts +++ b/packages/jest-reporters/src/NotifyReporter.ts @@ -125,6 +125,7 @@ export default class NotifyReporter extends BaseReporter { } else { this._notifier.notify( { + // @ts-expect-error - not all options are supported by all systems (specifically `actions` and `hint`) actions: [restartAnswer, quitAnswer], closeLabel: 'Close', hint: 'int:transient:1',