Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change jest test report output directory?

Tags:

node.js

jestjs

I have jest.config.js as below:

module.exports = {
  "roots": [
    "<rootDir>/src"
  ],
  "testMatch": [
    "**/__tests__/**/*.+(ts|tsx|js)",
    "**/?(*.)+(spec|test).+(ts|tsx|js)"
  ],
  "transform": {
    "^.+\\.(ts|tsx)$": "ts-jest"
  },
  "testResultsProcessor": "jest-sonar-reporter",
  "collectCoverage": true,
  "collectCoverageFrom": [
    "**/*.{ts,js}",
    "!**/node_modules/**"
  ],
  "coverageDirectory": "dist",
  "coverageReporters": ["lcov"]
}

A report file test-report.xml is generated in the project root directory. How can I make it to be saved in dist directory?

like image 403
Joey Yi Zhao Avatar asked Oct 20 '25 10:10

Joey Yi Zhao


2 Answers

Also you can configure it in jest configuration in package.json file

"jest": {
   "coverageDirectory": "<rootDir>/reports",
}
like image 125
Ivan Pruchai Avatar answered Oct 22 '25 01:10

Ivan Pruchai


According to your configuration a report file test-report.xml is generated by jest-sonar-reporter. You can change jest-sonar-reporter output directory by adding the following section to package.json:

"jestSonar": {
  "reportPath": "dist"
}

Reference: https://github.com/3dmind/jest-sonar-reporter

like image 35
Kaido Hallik Avatar answered Oct 22 '25 01:10

Kaido Hallik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!