Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Run jest tests passing two --testResultsProcessor options:
./node_modules/jest/bin/jest.js --testResultsProcessor=./processorA.js --testResultsProcessor=./processorB.js
Error:
โ Validation Error:
Module ./processorA.js,./processorB.js in the testResultsProcessor option was not found.
What is the expected behavior?
Both results processors are called back.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
jest: 21.0.2
node: 8.4.0
yarn: 1.0.0
OS: Linux Mint
Having such a feature would allow tools to implement jest integration using --testResultsProcessor and not worry about overwriting user-specified --testResultsProcessor.
E.g. currently WebStorm uses --setupTestFrameworkScriptFile for its jest integration. Well, it turned out to be not great (need to add IDE sources to transformIgnorePatterns and unmockedModulePathPatterns). Using jest-editor-support is too much as IDE needs TestResults only (also parent test suites are missing there for some reason). Seems tests results passed to test results processor (--testResultsProcessor) fit perfectly.
I don't think this needs to change. You can simply have a testResultsProcessor that wraps other test results processors:
module.exports = results => processA(processB(results));
that seems much more straightforward to me. What do you think?
@cpojer Yeah, delegation is a good approach (I thought about it and should have mentioned it, sorry). It will work, however, it has a downside: a tool has to run jest with --showConfig first to find out user-specified testResultsProcessor. It may take ~0.5 second to complete and might be annoying.
Since it's needed for tools, I'd be glad to work on a PR if this issue gets accepted.
I'm fine with a PR that turns this option into a string or array value instead of just string.
The thing to consider though is that the ordering may matter: the results processors may return any object that may not be the same one as before, it may have less information that the next processor expects.
Continuing what @cpojer already said: Combine test results processors using custom one:
http://wookieb.pl/multiple-testresultsprocessors-with-jest/
However, it would be nice if testResultsProcessor would accept an array
I'm gonna close this as composition solves this problem for now.
The link provided by @juhamust is now only accessible from https://web.archive.org/web/20171113152502/http://wookieb.pl/multiple-testresultsprocessors-with-jest/
Copied the solution from http://wookieb.pl/multiple-testresultsprocessors-with-jest/ here:
Create resultsProcessor.js file with the following content
module.exports = function() {
require('../node_modules/ts-jest/coverageprocessor').apply(this, arguments);
return require('../node_modules/jest-junit').apply(this, arguments);
// add any other processor you need
};
Remember to update package.json too
{
"jest": {
"testResultsProcessor": "./resultsProcessor"
}
}
Streamlined it a bit here: https://www.npmjs.com/package/jest-multiple-result-processors
Most helpful comment
Copied the solution from http://wookieb.pl/multiple-testresultsprocessors-with-jest/ here:
Create resultsProcessor.js file with the following content
Remember to update package.json too