-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Description
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
- Run
vue ui - Create a new project
- Presets: Manual
- Check
Babel,TypeScript, andUnit Testing - Pick a linter / formatter config:
ESLint Prettier(it's probably unrelated, but this is what I chose) - Pick a unit testing solution:
Jest - Create project
- Continue without saving
Post-project creation
- Enable Jest coverage collection from
package.json:jest.collectCoverage: true - Create a file
src/divider.tscontainingexport const divide = (a: number, b: number) => a / b; - Create a spec file
tests/unit/divider.spec.tscontaingtest('divide', () => { expect(divide(5, 2)).toEqual(2.5) }); - Run
yarn test:unitoryarn 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.
| service | written in... | test written in... | coverage collected? |
|---|---|---|---|
| substracter | TypeScript | TypeScript | No |
| divider | TypeScript | JavaScript | No |
| multiplier | JavaScript | TypeScript | Yes |
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:
- enable code coverage collection
- use
babel-jestfor handling.jsfiles, but it's not related I think
Thanks for your help (also you all did a great job on @vue/cli and vue ui! 🙂), do not hesitate to ask me for more info/context!