From b0daf41802dfbbe8a339b60f3d8bf91443297880 Mon Sep 17 00:00:00 2001 From: ron23 Date: Wed, 12 Feb 2020 22:48:50 -0800 Subject: [PATCH 1/2] show file path for obsolete snapshots --- SilentReporter.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/SilentReporter.js b/SilentReporter.js index ed1fa46..2f874df 100644 --- a/SilentReporter.js +++ b/SilentReporter.js @@ -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; @@ -32,17 +33,22 @@ 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'; + const hasUncheckedSnapshots = + !didUpdate && testResult.snapshot && testResult.snapshot.unchecked; + const hasFailures = testResult.failureMessage || hasUncheckedSnapshots; + + 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 From d8c5cf94cb628e87b65266ba5bd284329dcfe8c7 Mon Sep 17 00:00:00 2001 From: ron23 Date: Wed, 12 Feb 2020 22:59:18 -0800 Subject: [PATCH 2/2] add support for unmatched snapshot failures --- SilentReporter.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/SilentReporter.js b/SilentReporter.js index 2f874df..c1c0398 100644 --- a/SilentReporter.js +++ b/SilentReporter.js @@ -34,9 +34,17 @@ class SilentReporter { if (!testResult.skipped) { const didUpdate = this._globalConfig.updateSnapshot === 'all'; - const hasUncheckedSnapshots = - !didUpdate && testResult.snapshot && testResult.snapshot.unchecked; - const hasFailures = testResult.failureMessage || hasUncheckedSnapshots; + 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);