Skip to content

Commit ae562a7

Browse files
committed
don't ignore coverage doc
1 parent 9fcfd52 commit ae562a7

File tree

2 files changed

+104
-4
lines changed

2 files changed

+104
-4
lines changed

.gitignore

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
node_modules/
2-
coverage/
3-
.nyc_output/
4-
nyc_output/
1+
/node_modules/
2+
/coverage/
3+
/.nyc_output/
4+
/nyc_output/

docs/coverage/index.md

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
layout: layout
3+
---
4+
5+
# Coverage
6+
7+
This module uses [nyc](http://npm.im/nyc) to track code coverage, even
8+
across subprocess boundaries. It is included by default, and there's
9+
nothing you need to do but enable it. Adding coverage *will* make
10+
your tests run slightly slower, but that's to be expected.
11+
12+
Nyc in turn uses [istanbul](http://npm.im/istanbul) to do the actual
13+
coverage code transformation and reporting.
14+
15+
To generate coverage information, run your tests with the `--cov`
16+
argument.
17+
18+
If you use this a lot, you may want to add `coverage` and
19+
`.nyc_output` to your `.gitignore` and/or `.npmignore` files.
20+
21+
## Maximal Coverage 💯
22+
23+
As of version 7, node-tap lets you easily enforce 100% coverage of all
24+
lines, branches, functions, and statements with one easy flag, if
25+
that's your thing:
26+
27+
```json
28+
{
29+
"scripts": {
30+
"test": "tap test/*.js --100"
31+
}
32+
}
33+
```
34+
35+
If you do this in an open source module, please [join the exclusive
36+
100 club](/100/).
37+
38+
## Travis-CI and Coveralls.io Integration
39+
40+
You can very easily take advantage of continuous test coverage reports
41+
by using [Travis-CI](https://travis-ci.org) and
42+
[Coveralls](https://coveralls.io).
43+
44+
1. Enable Travis-CI by signing up, enabling tests on your repo, and
45+
adding a `.travis.yml` file to your repo. You can use [this
46+
module's .travis.yml file as an
47+
example](https://github.com/tapjs/node-tap/blob/master/.travis.yml)
48+
2. Enable Coveralls.io by signing up, and adding the
49+
repo. Note the repo API token.
50+
3. Back at Travis-CI, add a private environment variable. The name of
51+
the environment variable is `COVERALLS_REPO_TOKEN`, and the value
52+
is the token you got from Coveralls.
53+
4. When that token is set in the environment variable, `tap` will
54+
automatically generate coverage information and send it to the
55+
appropriate place.
56+
57+
## Uploading Coverage to Other Services
58+
59+
There's no requirement that you use Coveralls! Any coverage service
60+
that understands `lcov` can be used as well.
61+
62+
For example, using [CodeCov](https://codecov.io), you can do the
63+
following:
64+
65+
1. Add `codecov` as a devDependency in your project with this command:
66+
67+
npm install codecov --save-dev
68+
69+
2. Add a `test` script that generates coverage information, and a
70+
`posttest` that uploads it to codecov:
71+
72+
{
73+
"scripts": {
74+
"test": "tap test/*.js --coverage",
75+
"posttest": "tap --coverage-report=lcov && codecov"
76+
}
77+
}
78+
79+
## Local Coverage Reporting
80+
81+
Printing out a coverage report can be done along with tests, or after
82+
any covered test run, using the `--coverage-report=<type>` argument.
83+
84+
The most popular types are `text` and `html`, but any report style
85+
supported by istanbul is available, including:
86+
87+
- clover
88+
- cobertura
89+
- html
90+
- json
91+
- json-summary
92+
- teamcity
93+
- text
94+
- text-lcov
95+
- text-summary
96+
97+
To specify a report format, you can use `--coverage-report=<type>`.
98+
The default type is `text`, which produces a pretty text-only table on
99+
the terminal. If you specify `--coverage-report=html`, then tap will
100+
attempt to open a web browser to view the report after the test run.

0 commit comments

Comments
 (0)