Add coverage tracking in nodejs + coveralls support

This commit is contained in:
Slava Bacherikov committed 2018-01-28 17:04:36 +02:00
1 parent fa4b6c4f61
commit 38c6cc6eef
5 files changed
+59 -6

No files matched your search

+2
View File
@@ -10,3 +10,5 @@ dist/
*.env
coverage/
npm-debug.log
test-dist/
coverage-dist/
+2
View File
@@ -12,8 +12,10 @@ addons:
firefox: latest
script:
- npm test
- npm run cover
- npm run browser-test
- npm run lint
- ./ci/coveralls.sh
git:
depth: 1
submodules: false
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
cat ./coverage/lcov.info | $(npm bin)/coveralls || true
+46 -5
View File
@@ -2,16 +2,46 @@ var gulp = require("gulp");
var ts = require("gulp-typescript");
var tslint = require("gulp-tslint");
var jasmine = require("gulp-jasmine");
var sourcemaps = require('gulp-sourcemaps');
var istanbul = require("gulp-istanbul");
var remapIstanbul = require("remap-istanbul/lib/gulpRemapIstanbul");
var tsProject = ts.createProject("tsconfig.json");
gulp.task("build", function() {
gulp.task("coverage-build", function() {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(gulp.dest("dist"));
.js.pipe(sourcemaps.write('.', {includeContent: false}))
.pipe(gulp.dest("coverage-dist"));
});
gulp.task('test', ['build'], function() {
return gulp.src("dist/*.spec.js").pipe(jasmine());
gulp.task("pre-coverage", ["coverage-build"], function() {
return gulp.src(["coverage-dist/**/*.js"])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
gulp.task('coverage', ['coverage-build', 'pre-coverage'], function() {
return gulp.src("coverage-dist/*.spec.js")
.pipe(jasmine())
.pipe(istanbul.writeReports({
dir: './coverage',
reporters: ['json'],
reportOpts: {
json: {dir: './coverage', file: 'coverage-js.json'}
}
})).on("end", function () {
return gulp.src('coverage/coverage-js.json')
.pipe(remapIstanbul({
basePath: 'src/',
reports: {
'json': './coverage/coverage.json',
'html': './coverage/html-report',
'lcovonly': './coverage/lcov.info',
'text': null
}
}));
});
});
gulp.task('lint', function() {
@@ -20,4 +50,15 @@ gulp.task('lint', function() {
.pipe(tslint.report());
});
gulp.task('default', ['build', 'test', 'lint'])
gulp.task('test-build', function() {
return tsProject.src()
.pipe(tsProject())
.pipe(gulp.dest("test-dist"));
});
gulp.task('test', ['test-build'], function() {
return gulp.src("test-dist/*.spec.js")
.pipe(jasmine());
});
gulp.task('default', ['test', 'lint', 'coverage'])
+7 -1
View File
@@ -12,6 +12,7 @@
"gulp": "^3.9.1",
"gulp-tslint": "^8.1.2",
"gulp-typescript": "^3.2.3",
"gulp-sourcemaps": "^2.6.4",
"tslint": "^5.8.0",
"typescript": "^2.6.2",
"webpack": "^3.10.0",
@@ -22,11 +23,16 @@
"karma-sauce-launcher": "^1.2.0",
"karma-webpack": "^2.0.9",
"karma-sourcemap-loader": "^0.3.7",
"ts-loader": "^3.3.1"
"ts-loader": "^3.3.1",
"istanbul": "^0.4.5",
"gulp-istanbul": "^1.1.3",
"remap-istanbul": "^0.10.1",
"coveralls": "^3.0.0"
},
"scripts": {
"test": "gulp test",
"lint": "gulp lint",
"cover": "gulp coverage",
"browser-test": "karma start"
},
"repository": {