ankara-coverage v0.6.2
ankara
Code coverage tool leveraging babylon to cover es6/es7 and strawman proposals.
Usage
Installation
Install as npm package:
npm install ankara-coverage --save-devConfiguration
ankara is reading its configuration from an optional '.ankara.json' file in your project root.
{
"extensions": [
".js"
],
"files": [
"path/to/main.js"
],
"excludes": [
"**/node_modules/**"
]
}- The extensions key are all valid file types which should be covered.
- The files key should contain the main application/library entry points.
This is only requried if the
ankara instrumentbinary is used. - The excludes key should contain all sources not covered. This defaults to
'**/node_modules/**'
Execution
To create an lcov coverage report the easiest method is to create a wrapper
script which executes the test. Then call this script with the ankara cover command.
./node_modules/.bin/ankara cover <script-to-run-your-tests>Optionally one can use two steps.
First instrumenting your code:
./node_modules/.bin/ankara instrumentThen execute your tests with the covered sources.
Second generating lcov report:
./node_modules/.bin/ankara lcovThe instrumentation step could be done automatically with the provided require hook. Just import (or require) the register file from ankara.
import 'ankara/dist/register';Note: The register task is compatible with other register tasks but must be required as last step. This will then replace the previous registered tasks and execute them after instrumentation (e.g. babeljs/register).