How to use @jest/reporters - 6 common examples

To help you get started, we’ve selected a few @jest/reporters examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / addons-frontend / tests / jest-reporters / fingers-crossed.js View on Github external
/* eslint import/no-extraneous-dependencies: 0 */
const chalk = require('chalk');
const { getConsoleOutput } = require('jest-util');
const DefaultReporter = require('@jest/reporters/build/default_reporter')
  .default;
const getResultHeader = require('@jest/reporters/build/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) {
github mozilla / addons-frontend / tests / jest-reporters / fingers-crossed.js View on Github external
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
        )}`
      );
    }
  }
}
github mozilla / addons-frontend / tests / jest-reporters / summary.js View on Github external
/* eslint import/no-extraneous-dependencies: 0 */
const SummaryReporter = require('@jest/reporters/build/summary_reporter')
  .default;

module.exports = SummaryReporter;
github Khan / wonder-blocks / config / jest / log-on-fail-reporter.js View on Github external
/**
 * Only log console statements on when the test errors out.
 * From: https://gist.github.com/GeeWee/71db0d9911b4a087e4b2486386168b05
 */
const chalk = require("chalk");
const {getConsoleOutput} = require("jest-util");
const DefaultReporter = require("@jest/reporters/build/default_reporter")
    .default;
const getResultHeader = require("@jest/reporters/build/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 LogOnFailedTestReporter 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) {
github Khan / wonder-blocks / config / jest / log-on-fail-reporter.js View on Github external
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
        )}`
      );
        }
    }
}
github microsoft / just / scripts / jest-reporter.js View on Github external
const DefaultReporter = require('@jest/reporters').DefaultReporter;

/**
 * The purpose of this custom reporter is to prevent Jest from logging to stderr
 * when there are no errors.
 */
class JestReporter extends DefaultReporter {
  log(message) {
    process.stdout.write(message + '\n');
  }
}

module.exports = JestReporter;

@jest/reporters

Jest's reporters

MIT
Latest version published 1 year ago

Package Health Score

82 / 100
Full package analysis

Similar packages