Open wilhen01 opened 2 years ago
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This is a really small but annoying issue for us as well. There should be an easy way to get the test json output while having the nice CLI coverage during CI.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Bump.
+1 for this question, Similar problem: https://github.com/facebook/jest/issues/10914
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
bump
+1 for this question
Outstanding since 2017, closed by bot
Not a fix, but a practical workaround: instead of using --json --outputFile
, install a json-outputting reporter. The summary box is not supplanted by other reporters.
I'm using jest-json-reporter2
.
Thanks for the tip @StoneCypher. Does jest-json-reporter2
use the same output format as --json --outputFile
?
We're using the output file with DangerJS to show unit test results in our PRs, so it's only a good workaround for us if the format is the same.
Reporter2 has a short output and a long output. The short output is some simple summary statistics. For my project, the long output was 1.5 meg, and I didn't feel like digging through it. I honestly have no idea.
Cool, thanks, I'll have a play when I get a chance 👍
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Bump. I'd still like this fixed...
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Not stale. Again.
There is #12536 fwiw
While the PR is not merged, an workarround to get the same file can be:
jest --coverage --testResultsProcessor=my-results-processor.js
my-results-processor.js
const { writeFileSync } = require('fs')
const { join } = require('path')
const { formatTestResults } = require('@jest/test-result')
module.exports = (testResults) =>
writeFileSync(
join(process.cwd(), 'coverage', 'my-result.json'),
JSON.stringify(formatTestResults(testResults))
)
return testResults
}
Version
27.5.1
Steps to reproduce
npm install
npm run test-outputfile
to see output using --outputFile --jsonnpm run test-no-outputfile
to see output without those flagsExpected behavior
With code coverage configured. via
jest.config.js
I would expect to see CLI coverage output, regardless of the use of--outputFile --json
e.g.
Actual behavior
When using
--outputFile --json
the CLI coverage output is suppressed. Regular test output on the command line remains.e.g.
Additional context
No response
Environment