Jasmine 的 JavaScript 代码覆盖率

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16171589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 03:33:35  来源:igfitidea点击:

JavaScript code coverage with Jasmine

javascriptcode-coveragejasmine

提问by user153410

We are planning to introduce JavaScript unit testing in our project and so far Jasmine appears to be one of the better BDD unit testing frameworks for JavaScript. Now I am wondering how can we monitor code coverage of our JavaScript code. Are there any tools/plugins that we could use? We are a Microsoft shop and use .NET/MVC 4.

我们计划在我们的项目中引入 JavaScript 单元测试,到目前为止,Jasmine 似乎是用于 JavaScript 的更好的 BDD 单元测试框架之一。现在我想知道我们如何监控 JavaScript 代码的代码覆盖率。有没有我们可以使用的工具/插件?我们是一家微软商店,使用 .NET/MVC 4。

采纳答案by Andreas K?berle

There is the Istanbulcode coverage tool. And, as there is a grunt plugin for Istanbul/Jasmineit should work with Jasmine.

伊斯坦布尔代码覆盖工具。而且,因为有一个用于伊斯坦布尔/茉莉花grunt 插件,它应该可以与茉莉花一起使用。

回答by alxndr

A quick Googling turns up this blog postevaluating a bunch of options: Istanbul, Karma, Blanket.js, and JSCover.

一个快速的谷歌搜索出现了这篇博文,评估了一系列选项:IstanbulKarmaBlanket.jsJSCover

For Rails, the jasmine-coverage(based on JSCoverage) gem gives you a Rake task that generates output in different formats

对于 Rails,jasmine-coverage(基于JSCoverage) gem 为您提供了一个 Rake 任务,可以生成不同格式的输出

回答by rguitter

May be a little bit late, but if test coverage is important, you can also try mochawhich has a built-in support for test coverage, a good reputation too, a syntax close to jasmine and a good integration (grunt, karma, ...)

可能有点晚了,但是如果测试覆盖率很重要,您也可以尝试mocha,它具有对测试覆盖率的内置支持、良好的声誉、接近 jasmine 的语法和良好的集成(grunt、karma、. ..)