Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Fixes

- `[jest-cli]` Add check to make sure one or more tests have run before notifying when using `--notify` ([#6495](https://github.com/facebook/jest/pull/6495))
- `[jest-config]` Add missing options to the `defaults` object ([#6428](https://github.com/facebook/jest/pull/6428))
- `[expect]` Using symbolic property names in arrays no longer causes the `toEqual` matcher to fail ([#6391](https://github.com/facebook/jest/pull/6391))
- `[expect]` `toEqual` no longer tries to compare non-enumerable symbolic properties, to be consistent with non-symbolic properties. ([#6398](https://github.com/facebook/jest/pull/6398))
Expand Down
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
17 changes: 17 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 Expand Up @@ -84,6 +97,10 @@ const testModes = (notifyMode: string, arl: Array<AggregatedResult>) => {
);
previousContext = newContext;
reporter.onRunComplete(new Set(), ar);

if (ar.numTotalTests === 0) {
expect(notify.notify).not.toHaveBeenCalled();
}
});

expect(
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