在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):zordius/gulp-jsx-coverage开源软件地址(OpenSource Url):https://github.com/zordius/gulp-jsx-coverage开源编程语言(OpenSource Language):JavaScript 94.2%开源软件介绍(OpenSource Introduction):gulp-jsx-coverageEnable istanbul coverage on ES2015/babel files when you do mocha/jasmine tests, also deal with sourceMap for stack trace....as gulp task. deprecated Suggest to use jest to test, or use new istanbul/nyc directly. Features
ORIGINAL CODE/LINE in coverage reports ORIGINAL CODE/LINE in stack traces Usage
For Mocha tests:
For Jasmine tests:
Configure your .babelrc and install proper presets or plugins. Here is a .babelrc example:
And then:
Put this into your gulpfile.js: gulp.task('your_task_name', require('gulp-jsx-coverage').createTask({
src: ['test/**/*.js', 'test/components/*.jsx'], // your test files
})); Then run the task: Best Practices
Usage: General Mocha Test Creatorgulp.task('your_task_name', require('gulp-jsx-coverage').createTask({
src: ['test/**/*.js', 'test/components/*.jsx'], // will pass to gulp.src as mocha tests
istanbul: { // will pass to istanbul, this is default setting
exclude: /node_modules/ // do not instrument these files
},
threshold: [ // fail the task when coverage lower than one of this array
{
type: 'lines', // one of 'lines', 'statements', 'functions', 'banches'
min: 90
}
],
babel: { // this is default setting
include: /\.jsx?$/,
exclude: /node_modules/,
omitExt: false // if you wanna omit file ext when require(), put an array
}, // of file exts here. Ex: ['.jsx', '.es6'] (NOT RECOMMENDED)
coverage: {
reporters: ['text-summary', 'json', 'lcov'], // list of istanbul reporters
directory: 'coverage' // will pass to istanbul reporters
},
mocha: { // will pass to mocha
reporter: 'spec'
},
//optional
cleanup: function () {
// do extra tasks after test done
// EX: clean global.window when test with jsdom
}
})); Usage: Other Testing Frameworksvar GJC = require('gulp-jsx-coverage');
var jasmine = require('gulp-jasmine');
gulp.task('my_jasmine_tests', function () {
GJC.initModuleLoader(GJCoptions); // Refer to previous gulp-jsx-coverage options
return gulp.src('test/*.js')
.pipe(jasmine(jasmineOptions))
.on('end', GJC.collectIstanbulCoverage(GJCoptions)); // Refer to previous gulp-jsx-coverage options
}); Live Example: mochagit clone https://github.com/zordius/gulp-jsx-coverage.git
cd gulp-jsx-coverage
npm install
npm run mocha OUTPUT:
Upgrade Notice0.4.0
0.3.2
0.3.0
0.2.0
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论