Translations: Español, Français, Italiano, 日本語, Português, Русский, 简体中文
Use the nyc command-line-client for Istanbul to compute the code coverage of your tests.
First install nyc:
$ npm install --save-dev nyc
At its simplest run AVA through nyc. In your package.json
file:
{
"scripts": {
"test": "nyc ava"
}
}
You may want to exclude the .nyc_output
and coverage
directories from source control. Assuming you're using Git, add the following to your .gitignore
file:
.nyc_output
coverage
If you're compiling your source files using Babel you may want to apply Istanbul's instrumentation as part of the source file compilation. This will yield better results than instrumenting Babel's output. See Istanbul's Using Istanbul With ES2015+ tutorial. AVA sets NODE_ENV=test
for you. Note that as of February 2018 this tutorial hasn't yet been updated for Babel 7.