-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Jest coverage collection is not working with TypeScript files #1870
Comments
Have you tried setting The docs are not clear but if the example code provided thee is the default of jest, then typescript files are not included by default... |
Hum, actually you're right. I totally forgot about that because I thought it was implicit, but it's worse after specified it. Maybe it's not a |
Well... One of the latest issue on ts-jest is about a failing coverage, and the given solution works: "jest": {
"globals": {
"ts-jest": {
"disableSourceMapSupport": true
}
}
} But it's looks like a terrible fix. 😥 Also there is still I think this can be closed. |
If someone read this, this issue has been correctly fixed by updating |
Better solution than the above: To anyone reading, I have found a solution that keeps source maps and gives correct coverage (the above solution works but you only get line coverage information for the generated js files).
For some reason, when the source map is set inline in this way, jest properly collects coverage on the original ts files. |
Version
3.0.0-rc.3
Reproduction link
https://github.com/Kocal/vue-cli-no-coverage-on-typescript-files/commits/master
Steps to reproduce
Project creation
vue ui
Babel
,TypeScript
, andUnit Testing
ESLint Prettier
(it's probably unrelated, but this is what I chose)Jest
Post-project creation
package.json
:jest.collectCoverage: true
src/divider.ts
containingexport const divide = (a: number, b: number) => a / b;
tests/unit/divider.spec.ts
containgtest('divide', () => { expect(divide(5, 2)).toEqual(2.5) });
yarn test:unit
oryarn test:unit --no-cache
And under your eyes, you will see that coverage from
src/divider.ts
is not collected.What is expected?
Coverage from TypeScript files should be collected.
What is actually happening?
I investigate and this is what I found.
It really seems to be that when a file is written in TypeScript, its code coverage won't be collected.
Here is a Travis build that show Coverage state.
I'm a bit afraid because I'm actually migrating an app which uses
vuejs-templates/pwa
to@vue/cli 3
, but I literally lost all the code coverage... 😢Something strange too, code coverage from
.vue
files is not collected. 🤔Here is another Travis build that ran just after:
babel-jest
for handling.js
files, but it's not related I thinkThanks for your help (also you all did a great job on
@vue/cli
andvue ui
! 🙂), do not hesitate to ask me for more info/context!The text was updated successfully, but these errors were encountered: