-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation is due to jestjs/jest#4156 This is to get around travis-ci/travis-ci#4704 but is also much neater.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
module.exports = {}; | ||
module.exports = { | ||
reporters: ["<rootDir>/tests/jest-reporter.js"] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint import/no-extraneous-dependencies: 0 */ | ||
// https://github.com/mozilla/addons-frontend/commit/6bbf218dc3c3872cbe25654cb63ed0dfd367cf00 | ||
const chalk = require("chalk"); | ||
const { getConsoleOutput } = require("jest-util"); | ||
const DefaultReporter = require("jest-cli/build/reporters/default_reporter") | ||
.default; | ||
const getResultHeader = require("jest-cli/build/reporters/get_result_header") | ||
.default; | ||
|
||
const TITLE_BULLET = chalk.bold("\u25cf "); | ||
|
||
// This Jest reporter does not output any console.log except when the tests are | ||
// failing, see: https://github.com/mozilla/addons-frontend/issues/2980. | ||
class FingersCrossedReporter extends DefaultReporter { | ||
printTestFileHeader(testPath, config, result) { | ||
this.log(getResultHeader(result, this._globalConfig, config)); | ||
|
||
const consoleBuffer = result.console; | ||
const testFailed = result.numFailingTests > 0; | ||
|
||
if (testFailed && consoleBuffer && consoleBuffer.length) { | ||
// prettier-ignore | ||
this.log( | ||
` ${TITLE_BULLET}Console\n\n${getConsoleOutput( | ||
config.cwd, | ||
!!this._globalConfig.verbose, | ||
consoleBuffer | ||
)}` | ||
); | ||
} | ||
} | ||
} | ||
|
||
module.exports = FingersCrossedReporter; |