Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add check to make sure tests have run before notifying
  • Loading branch information
Taylor Winfield committed Jun 19, 2018
commit 09a7ca89972da8a091731527c763b91d5412655c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ Array [

exports[`test change 1`] = `
Array [
Object {
"message": "3 tests passed",
"title": "100% Passed",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be some snapshots added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that this is a result of the firstRun: i === 0 logic which is causing new snapshots in the the change testMode scenarios, due to me adding a new aggregation result to the notifyEvents array, so I believe this is expected?

Object {
"message": "3 of 3 tests failed",
"title": "100% Failed",
Expand All @@ -52,10 +48,6 @@ Array [

exports[`test failure-change 1`] = `
Array [
Object {
"message": "3 tests passed",
"title": "100% Passed",
},
Object {
"message": "3 of 3 tests failed",
"title": "100% Failed",
Expand Down
13 changes: 13 additions & 0 deletions packages/jest-cli/src/__tests__/notify_reporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,21 @@ const aggregatedResultsFailure: AggregatedResult = {
success: false,
};

const aggregatedResultsNoTests: AggregatedResult = {
numFailedTestSuites: 0,
numFailedTests: 0,
numPassedTestSuites: 0,
numPassedTests: 0,
numPendingTestSuites: 0,
numPendingTests: 0,
numRuntimeErrorTestSuites: 0,
numTotalTestSuites: 0,
numTotalTests: 0,
};

// Simulated sequence of events for NotifyReporter
const notifyEvents = [
aggregatedResultsNoTests,
aggregatedResultsSuccess,
aggregatedResultsFailure,
aggregatedResultsSuccess,
Expand Down
4 changes: 4 additions & 0 deletions packages/jest-cli/src/reporters/notify_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export default class NotifyReporter extends BaseReporter {
const notifyMode = this._globalConfig.notifyMode;
const statusChanged =
this._context.previousSuccess !== success || this._context.firstRun;
const testsHaveRun = result.numTotalTests !== 0;

if (
testsHaveRun &&
success &&
(notifyMode === 'always' ||
notifyMode === 'success' ||
Expand All @@ -60,6 +63,7 @@ export default class NotifyReporter extends BaseReporter {

notifier.notify({icon, message, title});
} else if (
testsHaveRun &&
!success &&
(notifyMode === 'always' ||
notifyMode === 'failure' ||
Expand Down