【问题标题】:karma-coverage: TypeError: Cannot read property 'split' of undefined业力覆盖:TypeError:无法读取未定义的属性“拆分”
【发布时间】:2017-06-01 03:04:03
【问题描述】:

我正在尝试通过因果报应来支持 lcov 记者。我像这样修改了我的业力配置:

 coverageReporter: {
       dir: 'reports/',
       reporters: [
          { type: 'in-memory' },
          { type: 'lcov', subdir: 'report-lcov' },
       ]

    },

我不断收到错误:

ERROR [coverage]: TypeError: Cannot read property 'split' of undefined
    at HtmlReport.writeDetailPage ({path}\node_modules\istanbul\lib\report\html.js:413:33)

我正在获取所需的报告,但此错误导致我的构建失败。 有没有办法解决这个问题?

【问题讨论】:

    标签: angular karma-coverage


    【解决方案1】:

    我能够通过使用不同的包来解决这个问题。业力重新映射伊斯坦布尔。

    Karma.conf.js 的变化

    remapIstanbulReporter: {
          remapOptions: {}, //additional remap options 
          reports: {
            'text-summary': null, // to display summary results on console
            json: 'coverage/coverage.json',
            lcovonly: 'coverage/lcov.info',
            html: 'coverage/html/',
          }
        },
        reporters: [  'mocha', 'coverage', 'karma-remap-istanbul'],
    

    webpack 测试配置的变化。我添加了 loader sourcemap-istanbul-instrumenter-loader 而不是 karma-remap-coverage 支持的 istanbul-intrumenter-loader

    {
              enforce: 'post',
              test: /\.(js|ts)$/,
              loader: 'sourcemap-istanbul-instrumenter-loader',
              include: helpers.root('src'),
              exclude: [
                /\.(e2e|spec)\.ts$/,
                /node_modules/
              ]
            }
    

    我能够顺利生成lcov报告。

    希望这可以帮助其他面临同样问题的人。

    【讨论】:

      猜你喜欢
      • 2020-12-29
      • 2022-01-18
      • 1970-01-01
      • 2018-07-27
      • 1970-01-01
      • 2019-04-06
      • 2016-12-30
      • 1970-01-01
      • 2023-03-24
      相关资源
      最近更新 更多