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

feat: add an option for showing test paths #11

Merged
merged 2 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ output dots for each test file, similar to a dot reporter.
}
```

Note: this config is also available as an environment variable `JEST_SILENT_REPORTER_DOTS=true`.

### showWarnings: boolean

Warnings are supressed by default, use `showWarnings` to log them.
Expand All @@ -63,7 +65,21 @@ Warnings are supressed by default, use `showWarnings` to log them.
}
```

Note: these options are also available as environment variables `JEST_SILENT_REPORTER_DOTS=true` and `JEST_SILENT_REPORTER_SHOW_WARNINGS=true`
Note: this config is also available as an environment variable `JEST_SILENT_REPORTER_SHOW_WARNINGS=true`.


### showPaths: boolean

Sometimes it might come in handy to display the test suites' paths (i.e. when
running tests in a terminal inside IDE for quicker file navigation).

```json
{
"reporters": [["jest-silent-reporter", { "showPaths": true }]]
}
```

Note: this config is also available as an environment variable `JEST_SILENT_REPORTER_SHOW_PATHS=true`.

## Screenshots

Expand Down
2 changes: 2 additions & 0 deletions SilentReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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.showWarnings =
!!process.env.JEST_SILENT_REPORTER_SHOW_WARNINGS ||
!!options.showWarnings;
Expand All @@ -32,6 +33,7 @@ class SilentReporter {

if (!testResult.skipped) {
if (testResult.failureMessage) {
if (this.showPaths) this.stdio.log('\n' + test.path);
this.stdio.log('\n' + testResult.failureMessage);
}
if (testResult.console && this.showWarnings) {
Expand Down