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',
},
coverageReporters: ['html'],
coverageThreshold: {
global: {
statements: 90,
functions: 90,
branches: 90,
},
},
moduleFileExtensions: ['js', 'vue'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/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):
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:
this vue component file can be report in coveage reports:
so what happened and what should I do ?