Tag: 伊斯坦布尔

摩洛哥伊斯坦布尔在反应的应用程序不正确的覆盖面

背景 我的项目包括: 一个带有jsx和js (包括*.test.js )文件的app/目录 调用instanbul的npm脚本: babel-node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha — \"./{,!(node_modules)/**/}*.spec.js\" –delay –compilers js:babel-core/register –recursive 我估计实际上我有3-5%的代码覆盖率 问题 当我运行报告时,数字要高得多: ======== Coverage summary ======== Statements : 93.24% ( 193/207 ) Branches : 41.67% ( 10/24 ) Functions : 92.45% ( 49/53 ) Lines : 94.12% ( 192/204 ) 也许instanbul不包括jsx文件,因为我有: jsx LOC的jsx js〜600 LOC 任何人都可以提供洞察到configuration – 谢谢 […]

unit testingnode.js模拟文件系统打开错误

我想提高我的代码覆盖这个function: function openArchiveFilePath(zipFilepath, next) { var fullyQualifiedZipFilepath = path.resolve(zipFilepath); fs.open(zipFilepath, 'r', openFile); function openFile(err, fd) { if (err) { if (err.code === FS_ERROR_CODE.FILE_NOT_FOUND_ERROR_CODE) { formatErrorMessageAndLog(err, "photo archive file (%s) doesn't exist.", fullyQualifiedZipFilepath); return next(err); } if (err.code === FS_ERROR_CODE.FILE_PERMISSIONS_ERROR_CODE) { formatErrorMessageAndLog(err, "photo archive file (%s) cannot be read, insufficient permissions.", fullyQualifiedZipFilepath); return next(err); } formatErrorMessageAndLog(err, […]

Nightmare.js和代码覆盖率

简洁版本: 我无法从我使用nightmare.js和mocha写的testing中看到代码覆盖率。 到目前为止,我已经尝试过使用伊斯坦布尔和_mocha。 大版本: 我有一个小项目: /public/index.html <html lang="en"> <head> <meta charset="UTF-8"> <title>My Website</title> <script src="./js/hello.js"></script> </head> <body> <h1>My Website</h1> </body> </html> /public/js/hello.js window.hello = function hello(){ return 'world'; }; 该网站使用快递和永远运行。 当我试图使用nightmare.js来testing它。 /test/test.js var path = require('path'); var Nightmare = require('nightmare'); var should = require('should'); /*global describe */ /*global it */ describe('Simple demo', function () { […]

编写unit testing使用child_process的节点服务

我有一个节点服务,我使用child_process spwan一个孩子,在我的情况下,孩子是一个C ++二进制文件,需要STDIN和streamSTDOUT。 该服务正在按预期工作,现在我正在尝试使用mocha / chai在服务中编写unit testing,并通过伊斯坦布尔运行testing。 我已经为这些stuufs奠定了基础,但只想获得如何为使用child_process的节点服务编写unit testing的示例。 基于这个例子,我可以尝试为我的服务编写unit testing,并在Instanbul上运行它们来生成覆盖率报告。 服务产生这样的孩子, var spawn = require('child_process').spawn, child = spawn(pathToBinary); child.stdin.write('JSON'); child.stdout.on('data', function (data) { //perform operations here });

伊斯坦布尔与巴贝尔有什么关系?

我正在尝试将代码覆盖范围添加到从ES2015转换的现有库中。 我似乎在做一切正确的事情。 我的生成文件读取 test: .FORCE export NODE_ENV=test babel *.js –out-dir lib nyc mocha 而我的babelrc读取 { "presets": ["es2015"], "sourceMaps": true, "env": { "test": { "plugins": ["istanbul"] } } } 而我的package.json包括 "nyc": { "include": [ "**/*.js" ], "require": [ "babel-register" ], "sourceMap": false, "instrument": false } 然而,我的testing运行后,输出简单地读取: ———-|———-|———-|———-|———-|—————-| File | % Stmts | % Branch | % […]

伊斯坦布尔代码覆盖:如何忽略这样的行?

当执行代码覆盖时,我所有的.catch()语句都被发现了,有没有一种方法可以指定/ * istanbul忽略next * / somewhere? 例如: function list(req, res, next) { const { limit = 50, skip = 0 } = req.query; User.list({ limit, skip }) .then(users => res.json(users)) .catch(e => next(e)); <= this line is marked as uncovered }

代码覆盖多个文件

我在使用摩卡框架的node.js中有一个应用程序。 我有两个JavaScript源文件,我想要代码覆盖(即a.js和b.js)。 为此,我正在使用伊斯坦布尔。 这里的问题是我没有得到如何采取代码覆盖多个文件。 我正在使用以下格式: istanbul cover node_modules/mocha/bin/_mocha a.js istanbul cover node_modules/mocha/bin/_mocha a.js b.js 但不幸的是,两个命令都给出了相同的代码覆盖率,我认为它只带了一个.js代码。 有没有find多个文件的代码覆盖率的解决scheme?

使用伊斯坦布尔对Node微服务进行集成testing

在进行集成testing的伊斯坦布尔覆盖面时,文档相当稀less。 当我通过我的摩卡testing时,我得到No coverage information was collected, exit without writing coverage information 。 我做的第一件事就是把我所有的源代码整理好: ✗ istanbul instrument . -o .instrument 就我而言,这是一个REST微服务,它是Docker化的,我已经写了Mochatesting来运行它来validation它,一旦它被部署。 我的期望是伊斯坦布尔会给我的代码覆盖从该节点服务的来源。 第二步我执行这个命令在我的testing代码上运行节点: ✗ istanbul cover –report none .instrument/server.js 之后,我运行我的testing使用以下从我的主要src目录如下(与结果): ✗ istanbul cover –report none –dir coverage/unit node_modules/.bin/_mocha — -R spec ./.instrument/test/** –recursive swagger-tests #createPet ✓ should add a new pet (15226ms) #getPets ✓ should exist […]

Node.js摩卡testingRestful API端点和代码覆盖率

我一直在享受伊斯坦布尔的乐趣,并尝试其他的Node.js覆盖库,但是我有一个问题。 几乎所有的unit testing都是对我的API的HTTP调用,如下所示: it('should update the customer', function (done) { superagent.put('http://myapp:3000/api/customer') .send(updatedData) .end(function (res) { var customer = res.body; expect(res.statusCode).to.equal(200); expect(customer.name).to.equal(updatedData.name); done(); }); }); 而不是实际需要customers.js文件并直接调用updateCustomer 。 testing端点对我来说更有意义,因为它不仅testingupdateCustomer ,而且还testing路由,控制器和其他所有参数。 这工作正常,但问题是,我似乎无法看到任何代码覆盖工具识别这些testing的方法。 伊斯坦布尔还有什么办法可以承认这些摩卡testing吗? 如果不是,那么约定是什么? 你如何testing端点,仍然使用代码覆盖工具?

我怎么能得到伊斯坦布尔与节点,摩卡,茉莉花和js要求

我有一个现有的testing套件,使用mocha,require和jasmine在node.js中正常运行,testing通过psake powershell脚本运行。 我正在尝试添加testing覆盖率,所以要运行unit testing而不是: 节点unitTest.js 我在做 伊斯坦布尔封面unitTest.js 这似乎工作,但只给了我关于unitTest.js本身的覆盖范围信息,但没有在项目中使用任何其他实际的JavaScript文件。 我猜这是因为要求/摩卡的组合,所以它不知道我使用的js文件。 我尝试手动将所有文件作为代码覆盖之前的一个步骤,并在复制/检测的文件上运行相同的命令,但得到相同的结果。 有关使这项工作的任何提示? 这是unitTest.js的最后一部分 requirejs(['mocha'], function(Mocha) { var mocha = new Mocha({reporter: (process.env['TEAMCITY_VERSION'] ? 'teamcity' : 'spec')}); // Hack to establish the global variables (sigh) mocha.suite.emit('pre-require', global, __filename, mocha); fswalk(__dirname, function(err, results) { if (err) console.warn(err); else { var testName = process.argv[2] || ""; console.log("testName: " + […]