2017-04-16 132 views
1

我试图让一个覆盖报告为我的测试案例,并安装伊斯坦布尔, 我覆盖率报告工作正常单个测试文件,该文件是在根文件夹中,否则我得到“No coverage information was collected, exit without writing coverage information”ExpressJs:伊斯坦布尔覆盖报告与摩卡

我的文件夹结构是

app/  
 — node_modules/ 
 — coverage/ 
 — server/ 
 — — app.js 
 — test/ 
 — — index.test.js 
 — test.js 

当我运行

istanbul cover _mocha test.js 

我得到一个覆盖报告但如果我尝试囤

istanbul cover _mocha test/*.js 

istanbul cover _mocha test/index.test.js 

我没有得到任何覆盖报告 我尝试全部命中和审判其不工作周围的任何工作一样吗?

如何运行istanbul来递归地涵盖所有测试用例的报告?

回答

0

所以实际上我误解伊斯坦布尔是如何工作的,

我正在运行的服务器作为单独的实例来运行测试用例,然后运行伊斯坦布尔。

所以我停止了服务器的运行实例,然后包含配置为istanbul运行服务器。

这有助于与您为测试用例保留的文件夹结构无关。

做摩卡的全球安装和伊斯坦布尔

npm install -g mocha istanbul 

FOR LINUX/MAC

NODE_ENV=testing_coverage istanbul cover _mocha ./server/tests/*/.js --recursive ./bin/www ; 
open coverage/lcov-report/*.html 

对于Windows

SET NODE_ENV=testing_coverage&istanbul cover ./node_modules/mocha/bin/_mocha ./server/tests/*/.js --recursive ./bin/www&open coverage/lcov-report/*.html 

WHERE

SET 

This is to be include in the windows to set the enviorment 

&this is to be included in windows to seperate the commands 

NODE_ENV=testing_coverage 
enviorment set for coverage and add this config in 
config.env file 

cover 
to cover istanbul code coverage, check istanbul help 

---recursive 
for running recursive test case 

_mocha 
For mac: mocha file in node_modules/.bin/_mocha 

./node_modules/mocha/bin/_mocha 
For windows set this path 

./bin/www 
Main file to start the application 

./server/tests/*/.js 
test cases folder path from root 

open coverage/lcov-report/*.html 
To open the coverage report in browser 
after all the test case gets completed 
相关问题