Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Trying to pass options to a coverage reporter (like you can with a normal reporter) fails with
Failed to write coverage reports:
ERROR: Error: Invalid report format [text,[object Object]]
The reporter supports options: https://github.com/gotwarlost/istanbul/blob/bc84c315271a5dd4d39bcefc5925cfb61a3d174a/lib/report/text.js#L38-L46
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
Config
"jest": {
"coverageReporters": [
[
"text",
{
"watermark": {
"statements": [
50,
80
],
"lines": [
50,
80
],
"functions": [
50,
80
],
"branches": [
20,
80
]
}
}
]
]
}
Then just run jest --coverage.
What is the expected behavior?
I should be able to pass options to coverage reporters just like normal reporters, as can be seen in its docs: https://facebook.github.io/jest/docs/en/configuration.html#reporters-array-modulename-modulename-options
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
[email protected], [email protected], [email protected]
+1
Any updates on this? This just bit me I was trying to change the filename of a coverage report through cobertura.
No news. PR welcome, though! 馃檪
I need the feature too. It will allow me to customize text reporter to show not fully covered items only.
Jest only calls Istanbul's createReporter and does a reporter.addAll(config.coverageReporters). Istanbul's code is here: https://github.com/istanbuljs/istanbuljs/blob/master/packages/istanbul-api/lib/reporter.js
Seems like we need to pass config to the createReporter call, and it somehow figures out which config is for which reporter later (https://github.com/istanbuljs/istanbuljs/blob/829e658dfa91e3a9533842be9ce940dbe7785c09/packages/istanbul-api/lib/reporter.js#L42-L43).
Jest's logic is here: https://github.com/facebook/jest/blob/08cb885400c538c6f934680adc3d0b51200a0228/packages/jest-cli/src/reporters/coverage_reporter.js#L90-L106
Logic for separating reporter names and config in Jest is in TestScheduler.js, that should probably be extracted (to handle turning Array<string | [string, Object]> into something a bit more usable)
Most helpful comment
Any updates on this? This just bit me I was trying to change the filename of a coverage report through cobertura.