-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a code coverage recipe #444
Conversation
a9d282c
to
70a4095
Compare
`coverage` to your `.gitignore`. | ||
|
||
|
||
## ES6 coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES6 => ES2015
70a4095
to
bd2baaa
Compare
Updated. 👍 |
"test": "nyc --reporter=lcov --reporter=text ava test.js" | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally prefer separating the coveralls stuff from the local test running. Meaning I don't see the point in having --reporter=lcov
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should look like:
"test": "nyc ava"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and in .travis.yml, you can do node_modules/.bin/nyc report --reporter=text-lcov
bd2baaa
to
5985784
Compare
Then add the following to your `.travis.yml`: | ||
|
||
``` | ||
after_script: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10f9dd1
to
155bb28
Compare
Just tried the ES2015 version without the reporters, it needs at least one otherwise it throws, so I'll leave in the text reporter for now. |
Can you report that as a bug to
|
Can you not hard wrap the text? |
```json | ||
{ | ||
"scripts": { | ||
"report": "nyc report --reporter html" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--reporter=html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nyc report --reporter html
works fine. Should I change anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I meant, for consistency, use =
between key and value.
155bb28
to
0cde9bb
Compare
0cde9bb
to
2ae27fe
Compare
Add it to the recipe list in the readme: https://github.com/sindresorhus/ava#recipes |
2ae27fe
to
858d3d0
Compare
Awesome! This will be helpful for a lot of users. Thanks @ben-eb :) |
No problem. 😄 |
To see a HTML report for either the ES6 or ES5 coverage strategies we have outlined, do: | ||
|
||
``` | ||
nyc report --reporter=html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be ./node_modules/.bin/nyc
unless installed globally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mine isn't. 😄
I know I'm a bit late to the party, but I had just a little bit of follow up. I usually inline the {
"test": "nyc --reporter=lcov --reporter=text ava"
} istanbuljs/nyc#137 is part of the reason why. Since the after_script:
- 'cat ./coverage/lcov.info | ./node_modules/.bin/coveralls' I prefer The In this case however, I wouldn't use it. Instead I would add it to AVA's config in {
"ava": {
"require": "babel-core/register"
}
} The advantage of configuring for AVA instead of NYC is that you can just run |
We used |
That adds bloat to your package.json with limited gain. The more boilerplate we add to package.json, the less likely it is people will bother using it. "People" here being me too.
That should just be fixed in
You can still have that locally, but I don't think failing PRs should add noise to the Coveralls history.
👍 |
@vdemedes Thoughts? |
I like this recipe, have nothing major to add or correct. The only thing I noted is that I usually prefix bash examples with |
@jamestalmage As for me, I also prefer having only nyc && ava in npm test. I generate lcov and pipe it to coveralls right away. The same stuff as in AVA's config. It looks clean and simple. |
Just a quick note; I don't have experience of other CI services and hosted code coverage, so if anyone would like to add other services to the bottom of the guide then that'd be useful. 😄