Stuck on generating a coverage report for the e2e test

297 Views Asked by At

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"
  }
}
1

There are 1 best solutions below

0
BuGaGa On

Add a flag to the test call command --coverage

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

Or this option:

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