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

🧪🧐 Code coverage ignores files that aren't covered by tests #1064

Open
JGreenlee opened this issue Apr 2, 2024 · 1 comment
Open

Comments

@JGreenlee
Copy link

JGreenlee commented Apr 2, 2024

In e-mission/e-mission-phone#1138 (comment), I noticed that coverage % dropped when I added more tests. I thought that was strange, so I started investigating.

As it turns out, it's not just .tsx files that are not being tracked by Jest coverage; it's all files that the tests don't cover.

It seems counter-intuitive to me, but I guess this is the default behavior for Jest coverage. Any files that the tests don't reach are completely ignored.
Since we mostly just have tests only for the .ts files (ie helper files which were converted from Angular services), and we don't have a lot of React component testing yet, our actual coverage % should be much lower.

I'm going to start an issue for this. In the meantime, I think we shouldn't put too much stock in the coverage %.

We set collectCoverage: true in the Jest config. But we don't have collectCoverageFrom.
When collectCoverageFrom is not given, Jest only considers files that were reached by the tests.

I think we should set collectCoverageFrom as follows:

...
collectCoverageFrom: [
    "www/js/**/*.{ts,tsx,js,jsx}",
    "!www/js/**/index.{ts,tsx,js,jsx}",
    "!www/js/types/**/*.{ts,tsx,js,jsx}",
  ],
...

@jiji14 can you handle this?

@jiji14
Copy link

jiji14 commented Apr 4, 2024

@JGreenlee sure, I will take care of this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants