Skip to content

Commit

Permalink
Enhance custom reporter options with TestRunner options
Browse files Browse the repository at this point in the history
The default summary reporter contains this line:

`this._write(getResultHeader(testResult, globalConfig) + '\n' + failureMessage + '\n');`

By replacing it with this:

`this._write(getResultHeader(testResult, globalConfig) + '\n');`

My tests run in 6 seconds instead of 30 (terminal seems to slow down when continuously printing lots of errors). I don't need the duplicate error messages in the summary because I can scroll up.

I decided the best solution would be to replace the default SummaryReporter. It looks like you're passing an object with `pattern`, `testNamePattern` & `testPathPattern` defined to the default SummaryReporter, but not to custom reporters & there's no way to access these variables.

Fix string usage for custom reporter

Fix lint errors
  • Loading branch information
ashtonsix authored and aaronabramov committed Jun 19, 2017
1 parent 20a9378 commit 66864bd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/jest-cli/src/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,15 @@ class TestRunner {
reporter: ReporterConfig,
): {path: string, options?: Object} {
if (typeof reporter === 'string') {
return {path: reporter};
return {options: this._options, path: reporter};
} else if (Array.isArray(reporter)) {
const [path, options] = reporter;
const [path] = reporter;
let [, options] = reporter;
options = Object.assign({}, this._options, options);
return {options, path};
}

throw new Error('Reproter should be either a string or an array');
throw new Error('Reporter should be either a string or an array');
}

_bailIfNeeded(
Expand Down

0 comments on commit 66864bd

Please sign in to comment.