Node.js ExpressJs:摩卡伊斯坦布尔报道
我试图获得测试用例的覆盖率报告,并安装了伊斯坦布尔, 对于根文件夹中的单个测试文件,我的覆盖率报告可以正常工作,否则我会得到Node.js ExpressJs:摩卡伊斯坦布尔报道,node.js,unit-testing,express,mocha.js,istanbul,Node.js,Unit Testing,Express,Mocha.js,Istanbul,我试图获得测试用例的覆盖率报告,并安装了伊斯坦布尔, 对于根文件夹中的单个测试文件,我的覆盖率报告可以正常工作,否则我会得到“没有收集到覆盖率信息,在不写入覆盖率信息的情况下退出” 我的文件夹结构是 app/ — node_modules/ — coverage/ — server/ — — app.js — test/ — — index.test.js — test.js 当我跑的时候 istanbul cover _mocha test.js 但是如果我尝试去tun,
“没有收集到覆盖率信息,在不写入覆盖率信息的情况下退出”
我的文件夹结构是
app/
— node_modules/
— coverage/
— server/
— — app.js
— test/
— — index.test.js
— test.js
当我跑的时候
istanbul cover _mocha test.js
但是如果我尝试去tun,我会得到一份报道
istanbul cover _mocha test/*.js
或
我没有收到任何报道
我试过了所有的点击和试用,但没有任何效果
我如何运行伊斯坦布尔以递归方式覆盖所有测试用例的报告?所以实际上我误解了伊斯坦布尔的工作原理 我将服务器作为单独的实例来运行测试用例,然后运行伊斯坦布尔 所以我停止了服务器的运行实例,然后包含config来运行伊斯坦布尔服务器 无论您为测试用例保留的文件夹结构如何,这都会有所帮助 在全球范围内安装摩卡和伊斯坦布尔
npm install -g mocha istanbul
适用于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
其中
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
所以实际上我误解了伊斯坦布尔的运作方式 我将服务器作为单独的实例来运行测试用例,然后运行伊斯坦布尔 所以我停止了服务器的运行实例,然后包含config来运行伊斯坦布尔服务器 无论您为测试用例保留的文件夹结构如何,这都会有所帮助 在全球范围内安装摩卡和伊斯坦布尔
npm install -g mocha istanbul
适用于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
其中
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