Tag: 代码覆盖

伊斯坦堡代码覆盖与摩卡咖啡testing与咖啡的脚本

我正在使用摩卡来运行纯粹在coffeescript中的testing。 我也希望能够使用伊斯坦布尔来生成代码覆盖率报告。 请注意,我在mocha.opts文件中使用了mocha选项–compilers coffee:coffee-script/register 。 我遇到的问题是,不包括需要其他coffeescript源文件的testing。 如果相反,我需要js文件,它覆盖的很好。 我错过了什么吗? 我的npm test命令是: istanbul test –report html -x 'vendor/**' _mocha 。 我使用npm test –coverage来执行伊斯坦布尔的覆盖实用程序。 下面是一个摩卡testing(./test/test.coffee)的示例: # Project # require ../src/main.coffee main = require('../src/main') # Chai chai = require('chai') assert = chai.assert should = chai.should() expect = chai.expect describe 'something', (done) -> describe "when given something", -> it "should […]

NodeJS应用程序中的function自动化Code​​Coverage

我正在寻找可以帮助我确定nodeJs中的function自动化覆盖的工具的指针。 (这不是unit testing!)。 我有很多运行在NodeJS中的前端应用程序的selenium自动化。 但是我想知道这些自动化的function覆盖面。 (我之前使用的是基于java的jacoco)

噶 – 伊斯坦布尔 – 代码覆盖率报告path

我使用karma作为茉莉花testing赛跑者,与instanbul作为代码覆盖工具。 所有的作品完美,但有一个问题 – 有什么办法可以改变创build报告的path? 即对于Chrome我得到/coverage/Chrome%2035.0.1916%20(Windows%207)/index.html ; 我会更喜欢/coverage/Chrome/index.html 任何build议非常感谢。

当在Nodeunit中使用Sandbox时,伊斯坦布尔的代码覆盖错误

我已经使用nodeunit编写了一堆testing来testing我的代码。 在这样做的时候,我想模拟被测代码所需的模块。 而不是改变代码,使其更容易与嘲笑testing,控制反转,当不需要,我改用了nodeunits沙箱function。 例 var nodeunit = require("nodeunit"); export.MyTest = { test1(test) { var fakeGlobals = { require: function(filename) { if (filename == "CoolUtil.js") { return { doit: function wasCool() { return true; } }; } else { return require(filename); } } }; var testSubject = nodeunit.utils.sandbox("ModuleUnderTest.js", fakeGlobals); test.equals(42, testSubject.doSomethingCoolUsingCoolUtil(), "Worked"); test.done(); } } 伊斯坦布尔给了我错误的报道数字。 […]

使用伊斯坦布尔和摩卡来覆盖ES6的代码

我有用ES6编写的Node代码,通过发布mocha –harmonytesting。 testing很好 – 一切正常。 现在我想添加覆盖和伊斯坦布尔的混合,但我不断遇到遇到的第一个箭头函数的错误: No coverage information was collected, exit without writing coverage information c:\Users\Guy\Code\alpha-dev\tests\helpers.js:12 setTimeout(() => { ^ SyntaxError: Unexpected token ) at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Module._extensions..js (module.js:478:10) at Object.Module._extensions..js (c:\Users\Guy\Code\alpha-dev\node_modules\istanbul\lib\hook.js:101:13) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) 这是我的尝试: 安装伊斯坦布尔和谐(从git://github.com/gotwarlost/istanbul.git#harmony)作为我的开发依赖。 运行以下命令: "./node_modules/.bin/istanbul" cover "./node_modules/mocha/bin/_mocha" — –harmony tests […]

如何在基于Express的API上设置代码覆盖率?

我一直在这个问题一段时间,我不能让现有的解决scheme为我工作。 我有一个用Express.js编写的Node.js API。 我一直在使用Mocha,Chai和Supertest为API编写testing。 这些testing主要是集成testing。 一个testing可能看起来像: it('should fail to register a new user without the proper information', function(done) { api.post('/user') .send({}) .expect(400) .expect('Content-Type', /json/) .end(function(err, res) { should.exist(res.body); should.exist(res.body.error); should.not.exist(err); res.body.error.should.contain('Username'); res.body.error.should.contain('password'); done(); }); }); 实际的testing工作很好,但现在我需要能够查看这些testing的代码覆盖率。 我必须知道我没有做足够的testing。 我尝试过使用摩卡的testing范围: mocha -R html-cov –coverage > coverage.html 和伊斯坦布尔的: istanbul cover _mocha — -R spec –timeout 5000 两者都遭受同样的问题: 你看,这是一个示例路线(用户注册)。 […]