Skip to content

Commit

Permalink
Fix code codcov integration (#258)
Browse files Browse the repository at this point in the history
* Update codecov to 3.5.0
* Strip 'build' dir from source maps in coverage file
  • Loading branch information
bingenito authored Jul 9, 2019
1 parent b3701a5 commit 9fb3b17
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 31 deletions.
60 changes: 36 additions & 24 deletions .gulp/tasks/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var jasmine = require('gulp-jasmine'),
istanbul = require('gulp-istanbul'),
replace = require('gulp-replace'),
remap = require('remap-istanbul/lib/gulpRemapIstanbul'),
instanbulEnforcer = require('gulp-istanbul-enforcer');

Expand All @@ -10,38 +11,49 @@ module.exports = function (gulp, config) {
return gulp.src(config.test.coverage.src)
.pipe(istanbul({ includeUntested: true }))
.pipe(istanbul.hookRequire())
.on('finish', function () {
.on('finish', () => {

// Run jasmine under istanbul
gulp.src(config.test.src)
.pipe(jasmine({ verbose: true, errorOnFail: true, includeStackTrace: false }))
.pipe(istanbul.writeReports({
dir: config.test.coverage.dest,
reporters: ['json']
}))
.on('end', remapCoverageFiles)
.on('finish', function () {
gulp.src('.')
.pipe(instanbulEnforcer({
coverageDirectory: config.test.coverage.dest,
rootDirectory: '',
thresholds: {
statements: config.test.coverage.threshold || 80

// Take js coverage json and remap to typescript. Output html and text
.on('end', () => {
return gulp.src(config.test.coverage.coverageFile)
.pipe(remap({
reports: {
'json': config.test.coverage.coverageFile, // overwrite js based json with ts remapped version
'html': config.test.coverage.dest,
'lcovonly': config.test.coverage.lcovFile,
'text': null
}
}));
});
});
}))

/** Take js coverage json and remap to typescript. Output html and text */
function remapCoverageFiles() {
return gulp.src(config.test.coverage.coverageFile)
.pipe(remap({
reports: {
'json': config.test.coverage.coverageFile, // overwrite js based json with ts remapped version
'html': config.test.coverage.dest,
'lcovonly': config.test.coverage.lcovFile,
'text': null
}
}));
};
// Remove staging build directory in code coverage for correct file mapping
.on('finish', function () {
return gulp.src(config.test.coverage.coverageFile)
.pipe(replace(/\\\\build\\\\src/mg, '\\\\src')) // windows
.pipe(replace(/\/build\/src/mg, '/src')) // unix)
.pipe(gulp.dest(config.test.coverage.dest))

// Enforce statement coverage threshold based on config or if not defined 80%
.on('finish', function () {
return gulp.src('.')
.pipe(instanbulEnforcer({
coverageDirectory: config.test.coverage.dest,
rootDirectory: '',
thresholds: {
statements: config.test.coverage.threshold || 80
}
}));
});
})
})
});
};
}

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ deploy:
skip_cleanup: true
on:
tags: true
branch: master
branch: master
21 changes: 16 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {},
"devDependencies": {
"codecov": "^3.0.0",
"codecov": "^3.5.0",
"dts-bundle": "^0.7.3",
"gulp": "^4.0.0",
"gulp-clean": "^0.4.0",
Expand Down

0 comments on commit 9fb3b17

Please sign in to comment.