I'm trying to get nyc
ava
and babel
to all place nice together. I was having an issue where async / await branches were showing as not covered, so this was working, I'm having trouble integrating the babel-plugin-istanbul
plugin for tests.
I have two files in the project, src/index.js
and src/test.js
.
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "ava",
"coverage": "NODE_ENV=test nyc npm run test",
"report": "nyc report --reporter=html",
"report:open": "open ./coverage/index.html",
"cover": "npm run coverage && npm run report && npm run report:open"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-runtime": "^6.26.0",
"bluebird": "^3.5.0",
"lodash": "^4.17.4"
},
"devDependencies": {
"ava": "^0.22.0",
"babel-cli": "^6.26.0",
"babel-plugin-istanbul": "^4.1.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.26.0",
"nyc": "^11.2.1",
"sinon": "^3.2.1",
"testdouble": "^3.2.4"
},
"babel": {
"presets": ["env"],
"plugins": ["transform-runtime"],
"env": {
"test": {
"plugins": ["istanbul"]
}
}
},
"ava": {
"require": ["babel-register"],
"babel": "inherit"
},
"nyc": {
"sourceMap": false,
"instrument": false
}
}
Here's whats running:
> [email protected] coverage /Users/me/Desktop/example
> NODE_ENV=test nyc npm run test
> [email protected] test /Users/me/Desktop/example
> ava
11 passed
----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files | Unknown | Unknown | Unknown | Unknown | |
----------|----------|----------|----------|----------|----------------|
> [email protected] report /Users/me/Desktop/example
> nyc report --reporter=html
> [email protected] report:open /Users/em/Desktop/example
> open ./coverage/index.html
Why isn't src/index.js
showing in the coverage?
Try to move
test.js
under some test foldertest/test.js