@build-chores/test
v0.9.0
Published
Testing JS projects is complicated.
Downloads
7
Readme
@build-chores/test
Testing JS projects is complicated.
Synopsis
Use your custom Babel configuration with the AVA test runner and instrument code coverage using nyc.
Usage
Install the @build-chores/test
package into your project:
yarn install --dev @build-chores/test [email protected]
To make use of AVA add the following entry to your package.json
. It will use your local .babelrc
to compile your source code and use babel-plugin-istanbul
to instrument the code. See the example package.json
for a template.
{
"ava": {
"require": "@build-chores/test"
}
}
ava
is declared as a peer dependency. This means it has to be installed along the @build-chores/test
package. Make sure to install either [email protected]
or ava@next
tag. The default ava
package installs a very old version.
Configure code coverage by placing a .nycrc
in your project root. See the example .nycrc
for a template.
{
"sourceMap": false,
"instrument": true,
"all": true,
"include": [
"src/**/*.js"
]
}
Please note that in order for all
to work and instrument all source files, instrument
has to be set to true
.
Provide the test
and coverage
script targets to your package.json
. AVA sets your NODE_ENV
to test
automatically. See the example package.json
for a template.
{
"scripts": {
"test": "ava",
"test:coverage": "nyc yarn test",
"test:watch": "yarn test -w"
}
}
You are ready to test your files.
Contribute
Check out our contributing.md to get started.