vuejs / vue-jest

Jest Vue transformer
MIT License
746 stars 157 forks source link

Vue files not included in coverage reports #488

Open zhenglong0034 opened 2 years ago

zhenglong0034 commented 2 years ago

jest: 28.1.3, vue-jest: 3.0.7 vue: 2.7.8

my jest.config.js is:

module.exports = { clearMocks: true, collectCoverage: true, collectCoverageFrom: ['src/*/.{js,vue}', '!/node_modules/'], transform: { '^[^.]+.vue$': 'vue-jest', '^.+\.js$': 'babel-jest', '.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': './mocks/fileMock.js', }, coverageThreshold: { global: { statements: 90, functions: 90, branches: 90, }, }, moduleFileExtensions: ['js', 'vue'], moduleNameMapper: { '^@/(.*)$': '/src/$1', }, };

when I use jest --coverage to run jest, I found some vue files not included in coverage reports, but some vue files is ok, (Sidebar/index.vue is not in, but CommonList/Item.vue is ok):

image

when compare these vue compoents files, I found that when vue component file has no "import", it did not in coverage reports, when import anything, import something:

image

this vue component file can be report in coveage reports:

image

so what happened and what should I do ?