// @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;
|