TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Istanbul: A JavaScript code coverage tool written in JS

42 pointsby sebslomskiover 10 years ago

13 comments

sheetjsover 10 years ago
I&#x27;m a fan of mocha + blanket for coverage: <a href="https://github.com/alex-seville/blanket" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alex-seville&#x2F;blanket</a><p>The mocha integration is incredibly easy:<p><pre><code> mocha --require blanket -R html-cov # for html output</code></pre>
illumenover 10 years ago
This is a brilliant tool for those of us who test JavaScript. A bit of a hack, but it seems to work.<p>It&#x27;s also a reason why browsers should allow some sort of tracing API for JavaScript. I know V8 and Firefox do not expose the interface because they couldn&#x27;t think of a decent enough use case to justify exposing the surface area of this code. This is the use case.
martin-adamsover 10 years ago
In case it&#x27;s useful for anyone, here is a gist of a gulpfile I use to use Istanbul to instrument my Node.js app, then run tests with Mocha and output the results:<p><a href="https://gist.github.com/medatech/76c6017cf55630b2db08" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;medatech&#x2F;76c6017cf55630b2db08</a>
评论 #8362536 未加载
jaegerpickerover 10 years ago
Ah that reminds me I wrote a coverage server for istanbul in node.js. It allows testem to send coverage statics across mutliple tests&#x2F;runs to reported on. It&#x27;s part of a whole test running package that I&#x27;m working on open sourcing that will allow testem (which is a great test runner if you don&#x27;t mind running all of your tests in one big session) to run multiple suites of tests. For instance if you have a order app and an client management app and you want separate test runs to avoid any namespace collisions the project allows you to define handlebars based templates to define your suites and run each suite with testem one at a time. Anyway here is a gist of the coverage server if it&#x27;s useful to anyone: <a href="https://gist.github.com/jaegerpicker/95c3900426d55eb9b857" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;jaegerpicker&#x2F;95c3900426d55eb9b857</a>
orkjover 10 years ago
I use this all the time. This is the command I use for coverage with mocha:<p>.&#x2F;node_modules&#x2F;istanbul&#x2F;lib&#x2F;cli.js cover -- .&#x2F;node_modules&#x2F;mocha&#x2F;bin&#x2F;_mocha -R spec<p>Always in my Makefile as make test-cov
fittomover 10 years ago
Great tool, perfectly fits to the node.js ecosystem, lightweight and fast.<p>However in case you use co-mocha[1] to test your generators, istanbul won&#x27;t work properly, the generators in the reports are shown as uncovered. Therefore I made a mocha fork[2] and directly applied the changes from co-mocha to the source (instead of monkey patching); it solved the problem.<p>[1] <a href="https://github.com/blakeembrey/co-mocha" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blakeembrey&#x2F;co-mocha</a> [2] <a href="https://github.com/tfitos/mocha" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tfitos&#x2F;mocha</a>
avelover 10 years ago
For rails projects, if you use the teaspoon gem as test runner (<a href="https://github.com/modeset/teaspoon" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;modeset&#x2F;teaspoon</a>), then you can easily get istanbul based coverage reports as well. It&#x27;s a good way to see which paths your js tests take in a large project and pinpoint untested code.
joshuaccover 10 years ago
Istanbul has been a godsend for my company&#x27;s JS-based projects. When paired with grunt-contrib-jasmine, it gives instant visibility into how much of the client-side app is actually under test, and gives everyone an incentive to keep improving coverage.
TheTurkishover 10 years ago
Why did you name it Istanbul?
评论 #8361227 未加载
gcb4over 10 years ago
i have some projects where the meat is in a cross domain connector. no way to test it in units. only functional test in real browsers cut it. otherwise it&#x27;s just red tape testing.<p>there is zero coverage tool for this case, until browsers wake up and give me a decent Dev api like opera 12 allowed
gomathinayagamover 10 years ago
sample LCOA Report links is broken, <a href="http://gotwarlost.github.io/istanbul/public/coverage/std-lcov/index.html" rel="nofollow">http:&#x2F;&#x2F;gotwarlost.github.io&#x2F;istanbul&#x2F;public&#x2F;coverage&#x2F;std-lco...</a>
tekromancrover 10 years ago
Wasn&#x27;t this project originally called &quot;Constantinople&quot;?
评论 #8364588 未加载
johnnymonsterover 10 years ago
why is this popping up now? its quite an old project at this point.