Allow configuring reporters for Jest
See original GitHub issueWould it be possible to add functionality to configure custom reporters for Jest, without doing an eject?
This kind of functionality is already implemented for coverage tools https://github.com/facebookincubator/create-react-app/issues/1785
My use case: I am running builds in Jenkins, and I would like to create JUnit XML formatted test reports so that the test results are nicely integrated with Jenkins UI.
I tried using this: https://www.npmjs.com/package/jest-junit and configured package.json
like this
"jest": {
"testResultsProcessor": "./node_modules/jest-junit"
}
The end result is this:
Out of the box, Create React App only supports overriding these Jest options:
• collectCoverageFrom
• coverageReporters
• coverageThreshold
• snapshotSerializers.
These options in your package.json Jest configuration are not currently supported by Create React App:
• testResultsProcessor
If you wish to override other Jest options, you need to eject from the default setup. You can do so by running npm run eject but remember that this is a one-way operation. You may also file an issue with Create React App to discuss supporting more options out of the box.
There is another reporter package that is seems to do similar thing: https://github.com/michaelleeallen/jest-junit-reporter
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Configuring Jest
Indicates whether the coverage information should be collected while executing the test. Because this retrofits all executed files with coverage ...
Read more >Configuring package.json · Jest
These options let you control Jest's behavior in your package.json file. ... A list of reporter names that Jest uses when writing coverage...
Read more >Supercharging Jest with Custom Reporters - Bruno Scheufler
The Jest configuration, located in jest.config.js , contains just the ... Now, let's get to the main part of our reporter: I installed...
Read more >use coverage reporters specified in Jest config when running ...
Jest : use coverage reporters specified in Jest config when running tests with coverage.
Read more >@jest/reporters | Yarn - Package Manager
Jest will set process.env.NODE_ENV to 'test' if it's not set to something else. You can use that in your configuration to conditionally setup...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should be able to pass it as a command line option. Since it doesn’t seem to make sense for non-CI runs, you might as well do it like this:
and then set your CI server to run
npm run test:ci
.Hope this helps!
@konekoya
"test:ci": "react-scripts test --env=jsdom --reporters=default --reporters=jest-junit",