All files index.js

100% Statements 6/6
100% Branches 4/4
100% Functions 2/2
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                        2x 1x                           1x   1x     1x       1x          
// @flow
import type { AggregatedResultWithoutCoverage } from './jest-types/TestResult';
import { reporter } from './reporter';
import { validate } from 'jest-validate';
import type { InitialOptions } from './jest-types/Config';
 
/**
 * The function used by jest to act as either a reporter or testResultsProcessor.
 * In this function we handle direction to either the supported reporter
 * or we direct to the deprecated testResultsProcessor.
 * @param globalConfig
 * @returns {AggregatedResultWithoutCoverage}
 * @constructor
 */
function JestMochaReporter(
  globalConfig : InitialOptions | AggregatedResultWithoutCoverage,
) {
  /**
   * Backwards compatibility for deprecated testResultsProcessor
   */
  if (globalConfig && globalConfig.hasOwnProperty('testResults')) {
    validate(
      {},
      {
        comment:
          'Please use jest reporter: https://github.com/jest-community/jest-junit#usage',
        title: {
          deprecation: 'testResultsProcessor support is deprecated',
        },
      },
    );
 
    /**
     * If we don't type cast flow complains :|
     */
    const report : AggregatedResultWithoutCoverage = (globalConfig : any);
 
    return reporter(report);
  }
 
  this.onRunComplete = (
    contexts : Object,
    report : AggregatedResultWithoutCoverage,
  ) => {
    return reporter(report, contexts);
  };
}
 
export default JestMochaReporter;