Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
:checkered_flag: Learn how to use the Istanbul JavaScript Code Coverage Tool
| Date | Stars |
|---|---|
| 2026-07-24 | 340 |
| 2026-07-25 | 340 |
| 2026-07-28 | 340 |
| 2026-07-30 | 340 |
| 2026-08-06 | 340 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
<div align="center">
# Learn Istanbul
<br />
[](https://travis-ci.org/dwyl/learn-istanbul)
[](https://codecov.io/github/dwyl/learn-istanbul?branch=master)
[](https://codeclimate.com/github/dwyl/learn-istanbul)
[](https://david-dm.org/dwyl/learn-istanbul?type=dev)
[](https://github.com/dwyl/learn-istanbul/issues)
[](https://hits.dwyl.io/dwyl/learn-istanbul)
<br />
Learn how to use Istanbul
to check/track Code Coverage in your JavaScript projects.
<br />
<img src="https://user-images.githubusercontent.com/194400/47108248-1adaf880-d243-11e8-9eeb-1f60a7a828db.jpg"
alt="Sign not in use!">
</div>
## Why?
Like the road sign that is "***Not In Use***" _most_ of the code
being written ***never*** gets ***executed***.
There are a *few* obvious issues with this:
1. if un-tested code remains in the codebase i
t can contain ***unknown behaviour*** e.g. ***bugs***.
2. untested features are more ***difficult to maintain***
without introducing ***breaking changes***.
3. un-tested code can ***clutter*** a project and accumulates [***technical debt***](https://en.wikipedia.org/wiki/Technical_debt) that ***wastes time***.
## What?
**Code coverage** tells you when code you have written is being executed
so you can decide if un-covered lines are [superfluous](https://www.google.com/search?q=superfluous)
(*and can be removed*) *or* require additional testing.
The rest of this page will focus on *practical* usage example, so
if you are completely new to Code Coverage we recommend you read the
wikipedia article: https://en.wikipedia.org/wiki/Code_coverage first.
*Istanbul* is a code coverage analysis script you run
when executing your unit tests:
https://github.com/gotwarlost/istanbul/
we like it because it's simple and prints out nice html reports (*see below*)
## How?
### Installation
We prefer to install istanbul as a "*devDependencies*" in each of our projects:
```sh
npm install istanbul --save-dev
```
to check if the installation worked, (*copy-paste and*)
run the following command in your terminal:
```sh
node_modules/.bin/istanbul help
```
### Simple Example
For our first example create a file called `test.js`.
```sh
vi test.js
```
type (*or copy-paste*) the following code in the `test.js` file:
```javascript
x = 42;
if(false)
x =-1;
```
Now run the istanbul command to generate a coverage report:
```sh
node ./node_modules/.bin/istanbul cover test.js
```
Alternatively you can insert the line
```json
"coverage": "istanbul cover ./test.js"
```
into the scripts section of your `package.json`
and run the following command in your terminal:
```sh
npm run coverage
```
This will create a directory in your project called **coverage**
where you will find the generated coverage reports.
In our case:
learn-istanbul/**coverage/lcov-report**/learning-istanbul/**test1.js.html**
<br />
If you open the test1.js**.html** file in your web browser
you will see a *visual* coverage report:

Istanbul gives us four code coverage metrics:
* **Statements**: How many of the [statements](https://www.2ality.com/2012/09/expressions-vs-statements.html)
in you code are executed.
* **Branches**: Conditional statements create branches of code
which may not be executed (e.g. `if/else`).
This metric tells you how many of your branches have been execuExcerpt of 10,723 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:c1627def9fa84436, topic:testing
matched fp:c1627def9fa84436, topic:tutorial