Skip to content

Commit

Permalink
show file path for obsolete snapshots (#23)
Browse files Browse the repository at this point in the history
* show file path for obsolete snapshots

* add support for unmatched snapshot failures
  • Loading branch information
ron23 committed Dec 1, 2020
1 parent 2d2d57b commit d8ace35
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions SilentReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class SilentReporter {
this._globalConfig = globalConfig;
this.stdio = new StdIo();
this.useDots = !!process.env.JEST_SILENT_REPORTER_DOTS || !!options.useDots;
this.showPaths = !!process.env.JEST_SILENT_REPORTER_SHOW_PATHS || !!options.showPaths;
this.showPaths =
!!process.env.JEST_SILENT_REPORTER_SHOW_PATHS || !!options.showPaths;
this.showWarnings =
!!process.env.JEST_SILENT_REPORTER_SHOW_WARNINGS ||
!!options.showWarnings;
Expand All @@ -32,17 +33,30 @@ class SilentReporter {
}

if (!testResult.skipped) {
if (testResult.failureMessage) {
if (this.showPaths) this.stdio.log('\n' + test.path);
this.stdio.log('\n' + testResult.failureMessage);
const didUpdate = this._globalConfig.updateSnapshot === 'all';
let hasSnapshotFailures = false;
if (testResult.snapshot) {
if (!didUpdate && testResult.snapshot.unchecked) {
hasSnapshotFailures = true;
}
if (testResult.snapshot.unmatched) {
hasSnapshotFailures = true;
}
}

const hasFailures = testResult.failureMessage || hasSnapshotFailures;

if (this.showPaths && hasFailures) {
this.stdio.log('\n' + test.path);
}
if (testResult.failureMessage)
this.stdio.log('\n' + testResult.failureMessage);
if (testResult.console && this.showWarnings) {
testResult.console
.filter(entry => entry.type === 'warn' && entry.message)
.map(entry => entry.message)
.forEach(this.stdio.log);
}
const didUpdate = this._globalConfig.updateSnapshot === 'all';
const snapshotStatuses = helpers.getSnapshotStatus(
testResult.snapshot,
didUpdate
Expand Down

0 comments on commit d8ace35

Please sign in to comment.