2017-04-16 85 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 
相關問題