【发布时间】:2022-09-27 15:58:29
【问题描述】:
开玩笑:28.1.3, Vue 笑话:3.0.7 Vue:2.7.8
我的 jest.config.js 是:
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\',
},
};
当我使用 jest --coverage 运行 jest 时,我发现一些 vue 文件未包含在覆盖率报告中, 但是有些vue文件没问题,(Sidebar/index.vue不在,但是CommonList/Item.vue没问题):
当比较这些vue组件文件时,我发现当vue组件文件没有“import”时,它没有在覆盖报告中, 导入任何东西时, 导入一些东西:
这个 vue 组件文件可以在 coveage 报告中报告:
那么发生了什么事,我该怎么办?