Switch to nyc, babel-plugin-istanbul & codecov-node for code coverage (#4885)
* Switch to nyc, babel-plugin-istanbul & codecov-node for code coverage This setup (very much like Babylon's) let us trace code coverage back to the `src/` directories of packages. * Exclude package tests from coverage report * fix: upgrade to version of nyc that tweaks a couple more things for babel * fix: remove comment based on @hzoo's review
This commit is contained in:
parent
f98d824ae7
commit
db67d7fdce
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,3 +16,4 @@ dist
|
||||
/packages/*/lib
|
||||
_babel.github.io
|
||||
/tests/.browser-build.js
|
||||
.nyc_output
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
instrumentation:
|
||||
root: .
|
||||
excludes:
|
||||
- "**/node_modules/**"
|
||||
- "scripts/*.js"
|
||||
18
Gulpfile.js
18
Gulpfile.js
@ -9,7 +9,6 @@ var gulp = require("gulp");
|
||||
var path = require("path");
|
||||
|
||||
var scripts = "./packages/*/src/**/*.js";
|
||||
var dest = "packages";
|
||||
|
||||
var srcEx, libFragment;
|
||||
|
||||
@ -21,6 +20,9 @@ if (path.win32 === path) {
|
||||
libFragment = "$1/lib/";
|
||||
}
|
||||
|
||||
var mapToDest = function (path) { return path.replace(srcEx, libFragment); };
|
||||
var dest = "packages";
|
||||
|
||||
gulp.task("default", ["build"]);
|
||||
|
||||
gulp.task("build", function () {
|
||||
@ -30,17 +32,17 @@ gulp.task("build", function () {
|
||||
gutil.log(err.stack);
|
||||
}
|
||||
}))
|
||||
.pipe(newer({map: mapToDest}))
|
||||
.pipe(through.obj(function (file, enc, callback) {
|
||||
file._path = file.path;
|
||||
file.path = file.path.replace(srcEx, libFragment);
|
||||
callback(null, file);
|
||||
}))
|
||||
.pipe(newer(dest))
|
||||
.pipe(through.obj(function (file, enc, callback) {
|
||||
gutil.log("Compiling", "'" + chalk.cyan(file._path) + "'...");
|
||||
gutil.log("Compiling", "'" + chalk.cyan(file.path) + "'...");
|
||||
callback(null, file);
|
||||
}))
|
||||
.pipe(babel())
|
||||
.pipe(through.obj(function (file, enc, callback) {
|
||||
file._path = file.path;
|
||||
file.path = mapToDest(file.path);
|
||||
callback(null, file);
|
||||
}))
|
||||
.pipe(gulp.dest(dest));
|
||||
});
|
||||
|
||||
|
||||
6
Makefile
6
Makefile
@ -52,13 +52,13 @@ test: lint test-only
|
||||
test-cov: clean
|
||||
# rebuild with test
|
||||
rm -rf packages/*/lib
|
||||
BABEL_ENV=test; ./node_modules/.bin/gulp build
|
||||
BABEL_ENV=test ./node_modules/.bin/gulp build
|
||||
./scripts/test-cov.sh
|
||||
|
||||
test-ci:
|
||||
NODE_ENV=test make bootstrap
|
||||
./scripts/test-cov.sh
|
||||
cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js
|
||||
make test-cov
|
||||
./node_modules/.bin/codecov -f coverage/coverage-final.json
|
||||
|
||||
publish:
|
||||
git pull --rebase
|
||||
|
||||
19
package.json
19
package.json
@ -11,6 +11,7 @@
|
||||
"async": "^1.5.0",
|
||||
"babel-core": "^6.13.2",
|
||||
"babel-eslint": "^7.0.0",
|
||||
"babel-plugin-istanbul": "^2.0.1",
|
||||
"babel-plugin-transform-class-properties": "^6.6.0",
|
||||
"babel-plugin-transform-flow-strip-types": "^6.3.13",
|
||||
"babel-plugin-transform-runtime": "^6.3.13",
|
||||
@ -22,7 +23,7 @@
|
||||
"bundle-collapser": "^1.2.1",
|
||||
"chai": "^3.5.0",
|
||||
"chalk": "1.1.1",
|
||||
"codecov.io": "^0.1.6",
|
||||
"codecov": "^1.0.1",
|
||||
"derequire": "^2.0.2",
|
||||
"eslint": "^3.9.0",
|
||||
"eslint-config-babel": "^2.0.1",
|
||||
@ -35,11 +36,11 @@
|
||||
"gulp-plumber": "^1.0.1",
|
||||
"gulp-util": "^3.0.7",
|
||||
"gulp-watch": "^4.3.5",
|
||||
"istanbul": "^0.4.5",
|
||||
"lerna": "2.0.0-beta.23",
|
||||
"lerna-changelog": "^0.2.0",
|
||||
"lodash": "^4.2.0",
|
||||
"mocha": "^3.0.0",
|
||||
"nyc": "^10.0.0",
|
||||
"output-file-sync": "^1.1.1",
|
||||
"rimraf": "^2.4.3",
|
||||
"semver": "^5.0.0",
|
||||
@ -65,8 +66,20 @@
|
||||
],
|
||||
"env": {
|
||||
"test": {
|
||||
"auxiliaryCommentBefore": "istanbul ignore next"
|
||||
"auxiliaryCommentBefore": "istanbul ignore next",
|
||||
"plugins": [
|
||||
"istanbul"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"nyc": {
|
||||
"all": true,
|
||||
"exclude": [
|
||||
"scripts/*.js",
|
||||
"packages/*/test/**"
|
||||
],
|
||||
"sourceMap": false,
|
||||
"instrument": false
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
node node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha -- `scripts/_get-test-directories.sh` --opts test/mocha.opts
|
||||
node_modules/.bin/nyc node_modules/mocha/bin/_mocha --opts test/mocha.opts `scripts/_get-test-directories.sh`
|
||||
node_modules/.bin/nyc report --reporter=json
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user