jest - coverage report now showing all files

Viewed 925

I am manually setting-up for jest.

My repo struture:

my-proj
 - src
  - components
   ...
   - accordion
    - index.jsx
  - tests
   - components
    - accordion.test.js
  - setupTests.js
 - package.json

When I run npm run test-coverage to get the test coverage, it only returns the files I've tested but not all files inside /src.

enter image description here

package.json

  "scripts": {
    "test": "jest --watchAll",
    "test-coverage": "jest --coverage", 
  },
  "jest": {
    "moduleDirectories": [
      "node_modules",
      "src"
    ],
    "moduleNameMapper": {
      "\\.(css|scss)$": "identity-obj-proxy"
    },
    "setupFilesAfterEnv": [
      "<rootDir>/src/setupTests.js"
    ],
    "snapshotSerializers": [
      "enzyme-to-json/serializer"
    ]
  },
1 Answers

I've just stumbled upon your question having the same problem as you do. Try running jest --coverage --watchAll. That should cover all files coverage and show which aren't, even without test files.

Related