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

remove notifier actions in case of failure #5861

Merged
merged 4 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 29 additions & 18 deletions packages/jest-cli/src/reporters/notify_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down