伊斯坦布尔和摩卡咖啡的报道
Coverage report with istanbul and mocha
我是 Node.js 的新手。我必须在我的应用程序中设置一些测试,我真的很生气试图在我的 loopback
应用程序中使用 mocha
和 istanbul
生成后端代码覆盖率报告。
在 Github 上搜索了数千篇 dab 解释文章,我发现了一些很好的 articles 然后我发现我必须使用这样的东西:
istanbul cover _mocha -- [path/to/test/files] -R spec
我很高兴,因为它说:"What you are essentially doing is passing the command to run your tests to Istanbul which, in turn, will run those tests on your behalf." 但是,每次我尝试 运行 伊斯坦布尔时,我都会收到此错误:
No coverage information was collected, exit without writing coverage information
C:\...\proj-name\node_modules\.bin\_mocha:2
basedir=$(dirname "$(echo "[=11=]" | sed -e 's,\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
我的工作测试文件是:
var userService = require('../TestBusinessLogic.js');
var should = require('chai').should();
describe('API Utenti', function() {
it('should throw Exception on missing UserName', function() {
(function() {
userService({ Name: 'Pippo', Surname: 'Baudo' });
}).should.Throw(Error);
});
});
这个命令好用吗?如果没有,有人可以解释一下如何使用 istanbul
和 mocha
制作覆盖率报告吗?
当从命令行 运行ning istanbul
需要从项目目录的根目录 运行 时,它默认查找文件 运行 目录根目录的覆盖率报告。
另外请确保您的测试文件夹路径是相对于您的项目目录的。
所以你应该使用 cd
导航到你的项目目录,然后在你的项目目录中然后 运行
istanbul cover _mocha -- ./path-to/test.js -R spec
认为我是 运行 node_modules\.bin\_mocha
而不是 node_modules\mocha\bin\_mocha
,这解决了我的问题。
我是 Node.js 的新手。我必须在我的应用程序中设置一些测试,我真的很生气试图在我的 loopback
应用程序中使用 mocha
和 istanbul
生成后端代码覆盖率报告。
在 Github 上搜索了数千篇 dab 解释文章,我发现了一些很好的 articles 然后我发现我必须使用这样的东西:
istanbul cover _mocha -- [path/to/test/files] -R spec
我很高兴,因为它说:"What you are essentially doing is passing the command to run your tests to Istanbul which, in turn, will run those tests on your behalf." 但是,每次我尝试 运行 伊斯坦布尔时,我都会收到此错误:
No coverage information was collected, exit without writing coverage information
C:\...\proj-name\node_modules\.bin\_mocha:2
basedir=$(dirname "$(echo "[=11=]" | sed -e 's,\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
我的工作测试文件是:
var userService = require('../TestBusinessLogic.js');
var should = require('chai').should();
describe('API Utenti', function() {
it('should throw Exception on missing UserName', function() {
(function() {
userService({ Name: 'Pippo', Surname: 'Baudo' });
}).should.Throw(Error);
});
});
这个命令好用吗?如果没有,有人可以解释一下如何使用 istanbul
和 mocha
制作覆盖率报告吗?
当从命令行 运行ning istanbul
需要从项目目录的根目录 运行 时,它默认查找文件 运行 目录根目录的覆盖率报告。
另外请确保您的测试文件夹路径是相对于您的项目目录的。
所以你应该使用 cd
导航到你的项目目录,然后在你的项目目录中然后 运行
istanbul cover _mocha -- ./path-to/test.js -R spec
认为我是 运行 node_modules\.bin\_mocha
而不是 node_modules\mocha\bin\_mocha
,这解决了我的问题。