Permalink
Browse files

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
  • Loading branch information...
1 parent f98d824 commit db67d7fdce4feed8c2a1aaa4ee353eb4fd60a5df @bcoe bcoe committed with hzoo Nov 28, 2016
Showing with 30 additions and 18 deletions.
  1. +1 −0 .gitignore
  2. +0 −5 .istanbul.yml
  3. +8 −6 Gulpfile.js
  4. +3 −3 Makefile
  5. +16 −3 package.json
  6. +2 −1 scripts/test-cov.sh
View
@@ -16,3 +16,4 @@ dist
/packages/*/lib
_babel.github.io
/tests/.browser-build.js
+.nyc_output
View
@@ -1,5 +0,0 @@
-instrumentation:
- root: .
- excludes:
- - "**/node_modules/**"
- - "scripts/*.js"
View
@@ -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);
+ gutil.log("Compiling", "'" + chalk.cyan(file.path) + "'...");
callback(null, file);
}))
- .pipe(newer(dest))
+ .pipe(babel())
.pipe(through.obj(function (file, enc, callback) {
- gutil.log("Compiling", "'" + chalk.cyan(file._path) + "'...");
+ file._path = file.path;
+ file.path = mapToDest(file.path);
callback(null, file);
}))
- .pipe(babel())
.pipe(gulp.dest(dest));
});
View
@@ -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
View
@@ -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
}
}
View
@@ -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

0 comments on commit db67d7f

Please sign in to comment.