Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests are passing but coverage is zero #2104

Closed
hamzahamidi opened this issue Nov 4, 2020 · 2 comments · Fixed by #2108
Closed

Tests are passing but coverage is zero #2104

hamzahamidi opened this issue Nov 4, 2020 · 2 comments · Fixed by #2108

Comments

@hamzahamidi
Copy link
Contributor

🐛 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",
@hamzahamidi hamzahamidi added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Nov 4, 2020
@hamzahamidi
Copy link
Contributor Author

I was able to solve this by changing the name of the file (index.ts)

@ahnpnl
Copy link
Collaborator

ahnpnl commented Nov 4, 2020

Duplicate with #2090

You need to clear jest cache first before running the tests.

@ahnpnl ahnpnl closed this as completed Nov 4, 2020
@ahnpnl ahnpnl added Not An Issue Not ts-jest issue and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Nov 4, 2020
@ahnpnl ahnpnl added Regression 💥 and removed Not An Issue Not ts-jest issue labels Nov 8, 2020
ahnpnl added a commit that referenced this issue Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants