-3

I have written E2E tests using Jest, Puppeteer, and ReactJS for a Chrome extension. And I am not getting how can I generate its coverage report. Nothing seems to be working.

I tried generating coverage reports with the jest-puppeteer-istanbul package with no jest-puppeteer and using ts-jest as preset in the Jest config.

// package.json
{
  ...
  "scripts": {
    ... 
    "test:e2e": "NODE_OPTIONS=\"--max_old_space_size=4096\" yarn jest --runInBand --detectOpenHandles e2e-tests",
    "test": "yarn test:e2e"
  },
  "jest": {
    "preset": "ts-jest",
    "testTimeout": 90000,
    "moduleDirectories": [
      "node_modules",
      "src"
    ],
    "collectCoverage": true,
    "collectCoverageFrom": [
      "src/pages/**/*"
    ],
    "reporters": [
      "default",
      "jest-puppeteer-istanbul/lib/reporter"
    ],
    "setupFilesAfterEnv": [
      "jest-puppeteer-istanbul/lib/setup"
    ],
    "coverageDirectory": "coverage"
  }
}
  • Show your package.json – BuGaGa Jun 13 '23 at 09:06
  • Have updated the description. – Himanshu singh Jun 13 '23 at 11:38
  • You cannot change the question, description, or code. If your question needs to be changed, then it's better to create a new question, and delete the old one. Because no one here likes to answer questions that are constantly changing and you wouldn't like it either. Don't forget to give a good rating to the comment or answer that caused the desire to change the question. The author of the answer or comment will be pleased – BuGaGa Jun 27 '23 at 06:32

1 Answers1

0

Add a flag to the test call command --coverage

"test": "yarn test:e2e --coverage"

Or this option:

"test": "yarn test:e2e -- --coverage"
BuGaGa
  • 302
  • 2
  • 9