just-scripts
Version:
Just Stack Scripts
29 lines • 840 B
JavaScript
;
// This doesn't have types for some reason
const { DefaultReporter } = require('@jest/reporters');
/**
* The purpose of this custom reporter is to prevent Jest from logging to stderr
* when there are no errors.
*/
class JestReporter extends DefaultReporter {
constructor() {
super(...arguments);
this._isLoggingError = false;
}
log(message) {
if (this._isLoggingError) {
process.stderr.write(message + '\n');
}
else {
process.stdout.write(message + '\n');
}
}
printTestFileFailureMessage(...args) {
this._isLoggingError = true;
super.printTestFileFailureMessage(...args);
this._isLoggingError = false;
}
}
// jest needs this format
module.exports = JestReporter;
//# sourceMappingURL=JestReporter.js.map