【问题标题】:Vue files not included in coverage reports覆盖率报告中不包含 Vue 文件
【发布时间】: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 报告中报告:

那么发生了什么事,我该怎么办?

    标签: vuejs2 jestjs vue-jest


    【解决方案1】:

    同样的问题!!你解决了吗?

    【讨论】:

    猜你喜欢
    • 2012-05-07
    • 1970-01-01
    • 1970-01-01
    • 2020-01-12
    • 2022-11-08
    • 2021-04-27
    • 2020-03-10
    • 2019-04-10
    • 2014-01-23
    相关资源
    最近更新 更多