gpt4 book ai didi

angularjs - 如何使用 Angular 2 CLI 设置 Istanbul 尔代码覆盖率?

转载 作者:太空狗 更新时间:2023-10-29 18:33:40 26 4
gpt4 key购买 nike

我不确定我是否了解 Istanbul 尔的设置。

所有教程只测试一个或两个文件。您如何设置它以便测试您的整个代码库?我理解错了吗?

最佳答案

我可以向您展示我的 karma.conf,它目前显示代码覆盖率(尽管我还没有让它与 Typescript 一起使用):

config.set({ 
basePath: "./",
frameworks: ["jasmine"],
files: [
//load files here, including your spec and source files
],
// Other settings...
browsers: ["PhantomJS"],
plugins: [
"karma-jasmine",
"karma-coverage", //<-- using karma-coverage for code coverage
"karma-chrome-launcher",
"karma-phantomjs-launcher"
],
// Coverage reporter generates the coverage
reporters: ["progress", "coverage"], //<-- reporter for code coverage
// Source files that you wanna generate coverage for.
// Do not include tests or libraries (these files will be instrumented by Istanbul)
preprocessors: {
"test/bin/js/app/**/!(*spec).js": ["coverage"] //<-- coverage pre-process
},
// Generate the code coverage report (lots of formats available)
coverageReporter: {
reporters:[
{ type: "html", dir: "./test/bin", subdir: "coverage/html" }
]
},
singleRun: true
})

在您的 package.json 中,包括“业力覆盖”:“1.1.1”作为开发依赖

希望这至少能为您指明正确的方向。

关于angularjs - 如何使用 Angular 2 CLI 设置 Istanbul 尔代码覆盖率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38854590/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com