不能使用Istanbul忽略代码覆盖中的行



我见过很多使用

的代码示例/*伊斯坦布尔忽略下一个//Istanbul ignore start//Istanbul ignore end */

在代码库中有一些地方是单元测试无法到达的,使用这些伊斯坦布尔指令来忽略它们会很好。不幸的是,尽管安装,重新安装,编辑配置文件等,我不能得到这个工作。

我使用以下语句:

  • IntelliJ IDEA 2021.2.4 (Ultimate Edition)
  • JetBrains Karma Plugin (212.4746.57)
  • Angular and AngularJS Plugin (212.5712.43)
  • Javascript and Typescript Plugin (212.5712.43)
  • Node Plugin (212.5712.43)
  • 节点14.15.5
  • npm 6.14.11
  • @angular - * 14.0.1
  • 茉莉花4.2.0
  • jasmine-core 4.2.0
  • jasmine-reporters 2.5.0
  • 业力6.4.0
  • karma-chrome-launcher 3.1.1
  • karma-cli 2.0.0
  • karma-coverage 2.2.0
  • karma-jasmine 5.0.1
  • source-map-support 0.5.21
  • ts-helpers 1.12
  • ts-node 10.8.1
  • tslib测试盒框
  • 打印稿4.7.3

从我的研究来看,伊斯坦布尔似乎是业力覆盖的一部分,尽管我已经看到了各种伊斯坦布尔相关的软件包。

我的karma.conf.js文件是:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/2.0/config/configuration-file.html
// This is for running locally in intellij - the intellij plugin doesn't support the parallel options we use via jenkins
module.exports = function (config) {
config.set({
files: [
'src/**/*.js'
],
// coverage reporter generates the coverage
reporters: ['progress', 'coverage'],
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('karma-junit-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
jasmine: {
verboseDeprecations: true
}
},
// you can define custom flags
customLaunchers: {
},
mime: {
'text/x-typescript': ['ts','tsx']
},
preprocessors: {
'src/**/*.js': ['coverage']
},
coverageReporter: {
dir: require('path').join(__dirname, 'coverage'),
// subdir: '.',
fixWebpackSourcePaths: true,
reporters: [
// reporters not supporting the `file` property
//{ type: 'html', subdir: 'report-html' },
{ type: 'lcov' /*, subdir: 'report-lcov' */ },
// reporters supporting the `file` property, use `subdir` to directly
// output them in the `dir` directory
//{ type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
//{ type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
//{ type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
//{ type: 'text', subdir: '.', file: 'text.txt' },
]
},
junitReporter: {
outputDir: 'test-results/unit/',
outputFile: 'test-results.xml'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage', 'junit']
: ['progress', 'kjhtml', 'junit'],
port: 9876,
colors: true,
logLevel: config.LOG_DEBUG, // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
hostName: 'localhost',
autoWatch: true,
usePolling: true,
singleRun: true,
// browsers: ['Chrome'],
browsers: ['ChromeHeadless'],
// browsers: ['Firefox'],
captureTimeout: 180000,
browserNoActivityTimeout : 210000,
reportSlowerThan : 500,
retryLimit: 0,                      // Fixes the issue where karma was starting up 3 browser tabs
browserDisconnectTimeout : 210000, // default 2000
browserDisconnectTolerance : 1, // default 0
random: false
});
};

看着Karma Server窗口,我没有看到"istanbul"这个词。我没有任何迹象表明伊斯坦布尔正在被使用。从//istanbul指令的使用来看,这并不是一件不寻常的事情。如果你能给我一些建议,我将不胜感激。

必须是https://github.com/karma-runner/karma-coverage/issues/247,伊斯坦布尔忽略注释不被业力报道记者尊重

最新更新