Skip to content

Commit

Permalink
feat: add an option for showing test paths (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Ricky <rickhanlonii@gmail.com>
  • Loading branch information
Konrad Madej and rickhanlonii authored Feb 6, 2020
1 parent a9512ec commit 0e5b682
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit 0e5b682

Please sign in to comment.