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

show file path for obsolete snapshots #19

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 11 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,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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should include some text I think, not just the path. log(`Obsolete snapshot at ${test.path}`) or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That text will be logged via helpers.getSnapshotStatus L60

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added result example in the description.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, perfect!

}
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