So Actually I misunderstood how Istanbul works,
I was running the server as separate instance to run the test case and then running the istanbul.
So I stopped the running instance of the server and then include config to run server for istanbul.
That helps irrespective of the folder structure you keep for your test cases.
Do global installation of mocha and 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
Where:
FOR 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