Configure Jest to create test results
Add jest-junit as dependency
Install the package jest-junit
as a development dependency:
npm install --save-dev jest-junit
yarn add --dev jest-junit
pnpm add --save-dev jest-junit
Create JUnit reports with Jest
Add the jest-junit
reporter to the jest config file to create JUnit report
files:
jest.config.json
{
"reporters": [
"default",
[
"jest-junit",
{
"outputDirectory": "<rootDir>/junit-reports",
"uniqueOutputName": "true",
"suiteName": "e2e tests",
"outputName": "e2e",
"addFileAttribute": "true",
"reportTestSuiteErrors": "true",
"includeConsoleOutput": "true",
"classNameTemplate": "{classname}",
"titleTemplate": "{title}",
"ancestorSeparator": " › "
}
]
]
}