Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

243
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda