Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
ExpressJs: Istanbul coverage report with mocha

I tried to get a coverage report for my test cases, and installed istanbul, My coverage report works fine for a single test file that is in root folder, else I get “No coverage information was collected, exit without writing coverage information”

My folder structure is

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

When I run 

istanbul cover _mocha test.js

I get a coverage report however If I try to tun

istanbul cover _mocha test/*.js

or

istanbul cover _mocha test/index.test.js

I don’t get any coverage report I tried all hit and trial its not working any work around for the same?

How can I run istanbul to cover report for all the test cases recursively ?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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

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

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
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!