Vidushika Dasanayka
Vidushika Dasanayka

Reputation: 159

How to create code coverage reports for React with jest Junit?

I'm working on a React typescript project and I want to generate a results of the tests and coverage as an xml file in project root. I have installed jest-junit and jest-junit-reporter. But unfortunately, I'm unable to generate a coverage report.

Here you can fing my package.json file

{
  "name": "#",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "start": "nx serve",
    "build": "nx build",
    "test": "jest --coverage --jest-junit.xml",
    "devstart": "nx serve shell --open --devRemotes=dashboard"
  },
....
"jest": {
    "testResultsProcessor": "./node_modules/jest-junit-reporter",
    "coverageReporters": [
      "text"
    ],
    "reporters": [
      "default",
      "jest-junit"
    ]
  },
   "jest-junit" :{ "outputDirectory": "test_results", "outputName": "jest-junit.xml"}
}

Can someone assist me in this issue? What's the error I have done in here?

Upvotes: 0

Views: 800

Answers (0)

Related Questions