Skip to content

Tests are passing but coverage is zero #2104

@hamzahamidi

Description

@hamzahamidi

🐛 Bug Report

I'm developing a small library ( just an index.ts and index.spec.ts for tests) and apparently jest is ignoring the coverage from index.ts although the tests are passing!
image

To Reproduce

Steps to reproduce the behavior:

npm init
npm i -D webpack webpack-cli @webpack-cli/init

Init the project with default typescript settings:

webpack init
npm i -D jest typescript  ts-jest @types/jest
npx ts-jest config:init
npm run test -- --collect-coverage

This the structure of the project:

image

jest.config:

module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'jsdom',
  roots: [
    "<rootDir>/src"
  ]
};

Expected behavior

Collect coverage

Link to repo (highly encouraged)

Debug log:

# content of ts-jest.log :

envinfo

System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node

Npm packages:
    jest: 26.6.1
    ts-jest: 26.4.3
    typescript: 4.0.5
    "@babel/core": "^7.12.3",
    "@babel/preset-env": "^7.12.1",
    "@types/jest": "^26.0.15",

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions