Created
January 17, 2017 17:28
-
-
Save barretts/db9097d4a988a56b54a585e3085a7d06 to your computer and use it in GitHub Desktop.
Code coverage sample files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = require('config.json'); | |
var fs = require('fs'); | |
var gulp = require('gulp'); | |
var mochaPhantomJS = require('gulp-mocha-phantomjs'); | |
var webpack = require('webpack'); | |
var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul'); | |
var coverageFile = './results/coverage/coverage.json'; | |
gulp.task('webpack-coverage', function (cb) { | |
var webpackConfig = require('webpack-coverage.config'); | |
webpack(webpackConfig, function (err) { | |
if (err) throw new Error('webpack', err); | |
cb(); | |
}); | |
}); | |
gulp.task('coverage', ['webpack-coverage'], function () { | |
return gulp | |
.src(config.files.tests) | |
.pipe(mochaPhantomJS({ | |
phantomjs: { | |
hooks: 'mocha-phantomjs-istanbul', | |
coverageFile, | |
ignoreResourceErrors: true, | |
}, | |
reporter: 'dot', | |
})) | |
.on('finish', function () { | |
gulp.src(coverageFile) | |
.pipe(remapIstanbul({ | |
reports: { | |
html: './results/coverage', | |
}, | |
warn: () => {}, | |
})); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = require('./webpack.config')[0]; // regular config for production and development builds | |
var path = require('path'); | |
config.devtool = '#inline-source-map'; | |
config.entry = './specs/testRunner.js'; | |
config.output.filename = 'coverage.bundle.js'; | |
config.resolve.root.push(path.join(__dirname, 'specs')); | |
config.module.loaders[config.module.loaders.length - 1] = { | |
exclude: /(node_modules)/, | |
loader: 'babel-loader', | |
test: /\.jsx?$/, | |
query: { | |
presets: ['es2015'], | |
plugins: [ | |
['istanbul', { | |
exclude: [ | |
'specs/**/*.js', | |
'dist/**/*.js', | |
'node_modules/**/*.js', | |
], | |
}], | |
], | |
}, | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment