Tag: istanbul

“伊斯坦布尔”不被视为内部或外部命令

我刚刚添加了istanbultesting覆盖模块到我的node.js应用程序,但是当我运行(从命令提示符): > instanbul cover myTests.js 正如文档中提到的,我得到: 'istanbul' is not recognized as an internal or external command 我在Windows 7下.npm安装没有返回错误。 我没有看到有关额外安装步骤的文档。 我错过了什么?

用伊斯坦布尔装载mongoose模型

我想为我们的项目实现代码覆盖,所以我们使用grunt-istanbul。 我坚持这个教程: https : //github.com/taichi/grunt-istanbul 我的问题是,当运行针对工具化源代码的testing时,我得到这个错误,但它运行正常代码的testing时正常工作。 >> Mocha exploded! >> MongooseError: Schema hasn't been registered for model "Comm". >> Use mongoose.model(name, schema) >> at Mongoose.model (/Users/user/repos/review.ninja/node_modules/mongoose/lib/index.js:322:13) >> at Object.<anonymous> (/Users/user/repos/review.ninja/test/coverage/instrument/src/server/api/comm.js:9:147) >> at Module._compile (module.js:449:26) >> at Object.Module._extensions..js (module.js:467:10) >> at Module.load (module.js:349:32) >> at Function.Module._load (module.js:305:12) >> at Module.require (module.js:357:17) >> at require (module.js:373:17) >> […]

伊斯坦布尔代码覆盖检查覆盖我的规范文件,而不是源?

刚开始使用代码覆盖工具,但我想我已经正确设置了一切。 然而,伊斯坦布尔正在生成我的规范文件,而不是源文件的覆盖率报告? 当我运行jasmine-node repeatSpec.js –verbose 我得到: repeat Start repeats strings – 1 ms repeat Finish – 3 ms Finished in 0.004 seconds 1 Tests, 0 Failures, 0 Skipped 这是正确的,如果我故意失败了我的testing,它也会失败。 但是,当我运行这个istanbul命令: istanbul cover /d/Users/rkan/AppData/Roaming/npm/node_modules/jasmine-node/bin/jasmine-node repeatSpec.js 我得到这个回应,这是根据我的spec文件检查覆盖范围。 ============================================================================= Writing coverage object [d:\playground\ue\node\Domain\WorkQueue\tests\coverage\coverage.json] Writing coverage reports at [d:\playground\ue\node\Domain\WorkQueue\tests\coverage] ============================================================================= =============================== Coverage summary =============================== Statements : 100% ( 5/5 […]

我如何获得伊斯坦布尔的Lab / Hapi.jstesting报告?

编辑:几个月后,我完全迁移到实验室,它的工作很好,包括覆盖。 也许在我写这个实验室的时候没有一个好的覆盖工具。 我已经得到了这个工作。 今天早上工作 突然间,事实并非如此。 testing在dist/test/unit.js 。 15个testing覆盖了80.29%的代码(基于Lab的覆盖报告)。 但是我们准备和Sonar一起使用伊斯坦布尔,所以我需要再次与伊斯坦布尔合作。 无论如何我宁愿select伊斯坦布尔 我正在运行testing: ./node_modules/.bin/istanbul cover ./node_modules/.bin/lab — -l -e development -r lcov dist/test testing运行。 全部通过。 屏幕输出是覆盖报告: … DA:801,1 DA:802,1 DA:803,1 DA:804,1 DA:805,1 DA:806,1 DA:807,1 LF:774 LH:738 end_of_record No coverage information was collected, exit without writing coverage information 为什么这告诉我没有收集报道? 我怎样才能让这两个工具再次打好? 摆脱-r lcov并没有真正的帮助。 在./coverage (默认文件夹)中没有任何输出。 我可以通过pipe道强制它,但是当我运行输出到伊斯坦布尔(报告选项)时,我得到Error: Invalid report format […]

覆盖伊斯坦布尔和摩卡/柴的function

我无法理解如何unit testingfunction,以便伊斯坦布尔会考虑它们。 举一个非常简单的例子,我创build了这个math模块: var add = function( one, two ){ return one + two; } module.exports = { add: add }; 和基本的unit testing: var chai = require('chai'); var expect = chai.expect; describe('add() method', function(){ it('should do math', function(){ expect( some.add(1, 1) ).to.equal(2); }); }); 伊斯坦布尔的报告给了我这些结果: 发言:66.67%(2/3) 分支机构:100%(0/0) function:0%(0/1) 行数:66.67%(2/3) 忽略:无 如果简单地testing调用函数的结果不算作覆盖率,那么在unit testing无法访问的函数范围内,如何testing此代码?

我可以使用伊斯坦布尔为摩卡html-cov的仪器

我正在尝试使用istanbul instrument输出mocha -R html-cov但不能得到它的工作。 我的testing脚本是: test: post: – node_modules/.bin/istanbul cover node_modules/.bin/_mocha -dir $CIRCLE_ARTIFACTS — -u exports -R spec – node_modules/.bin/istanbul instrument . -o lib-cov – cp package.json lib-cov/ # needs to be copied manually – MY_LIB_COV=1 node_modules/.bin/mocha -R html-cov > $CIRCLE_ARTIFACTS/coverage.html 我的testing有以下开关: var mylib = process.env.MY_LIB_COV ? require('../lib-cov') : require('../'); 伊斯坦布尔在lcov-report/index.html给了我一个很好的输出。 摩卡的html-cov在coverage.html给了我'0%覆盖率0 SLOC' 伊斯坦布尔的lcov报告是丑陋的。 我想用漂亮的mocha […]

当在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(); } } 伊斯坦布尔给了我错误的报道数字。 […]

生成伊斯坦布尔代码覆盖率报告为茉莉花testing运行(通过咕噜)phantomjs的一个browserify包

标题说明了一切。 尽pipe通过networking浏览,我还没有find一个解决这个问题的例子。 这里有一些错过 https://github.com/amitayd/grunt-browserify-jasmine-node-example – grunt,browserify和jasmine https://github.com/gotwarlost/istanbul/issues/59#issuecomment-18799734 – browserify和伊斯坦布尔 这里是我正在进行的代码https://github.com/wheresrhys/on-guard/tree/browserify (注意这是“browserify”分支 – Gruntfile.js是一个混乱,但将很快整理)。 我最初的调查使用console.log表明,不知何故bundle.src.js被加载到页面中,但是当testing运行(并通过!) bundle.src.js的代码没有运行,所以我有一个感觉这可能是一个混淆的问题…虽然一个仅限于phantomjs,因为当我打开铬的specrunner代码正在运行。

在使用Karma和伊斯坦布尔时不包括覆盖范围内的文件

我使用Karma来testing我的JavaScript并获得覆盖率报告。 我正在使用伊斯坦布尔的覆盖报告,这是默认的。 这是我的预处理器参数: preprocessors: { 'framework/**/*.js':'coverage', 'framework/*.js':'coverage', '!framework/node/**/*.js':'coverage', '!framework/test/**/*.js':'coverage', 'framework-lib/**/*.js':'coverage', '!framework-lib/tool-data-api/tool-data-api.js':'coverage' } 正如你所看到的,我正在尝试使用“!” 作为否定命令,通常与Node一起使用。 然而,这不是在这里工作,没有我的目录被排除在外。 有什么办法可以做我想做的事情吗?

Grunt代码覆盖不起作用

我有下面这个运行mochatesting的grunt文件OK(运行grunt.js后我得到testing结果)现在我想添加一个代码,并使用https://github.com/taichi/grunt-istanbul模块。 但是当我运行grunt.js什么也没有发生,有什么想法? 我想要的只是之后,摩卡testing正在运行它将运行代码覆盖与一些报告 ? 任何新的代码覆盖将是伟大的 这是我的项目结构 myApp -server.js -app.js -test -test1.spec -test2.spec -test-reports -grunt.js -utils -file1.js -file2.js -controller -file1.js -file2.js 这是我尝试过的咕噜声中的代码 module.exports = function (grunt) { var path = require('path'); process.env.RESOURCE_PATH_PREFIX = "../"; var d = new Date(); var datestring = d.getDate() + "-" + (d.getMonth() + 1) + "-" + d.getFullYear() + " " […]