
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
gulp-jsx-coverage
Advanced tools
Enable istanbul or isparta coverage on ES2015/babel or coffee-script/cjsx files when you do mocha/jasmine tests, also deal with sourceMap for coverage report and stack trace.
Enable istanbul or isparta coverage on ES2015/babel or coffee-script/cjsx files when you do mocha/jasmine tests, also deal with sourceMap for coverage report and stack trace.
Check this chart to see features when gulp-jsx-coverage work with different coverage tools:
Features \ Coverage Tool | istanbul | isparta |
---|---|---|
Mocha testing | ✅ | ✅ |
Jasmine testing | ✅ | ✅ |
syntax: jsx | ✅ | ✅ |
syntax: ES2015 | ✅ | ✅ |
syntax: coffee-script | ✅ | ❌ |
syntax: cjsx | ✅ | ❌ |
coverage report | transpiled | original |
npm install gulp-jsx-coverage mocha --save-dev
require('file.jsx')
.require('file.coffee')
.require('file.cjsx')
.gulp.task('your_task_name', require('gulp-jsx-coverage').createTask({
src: ['test/**/*.js', 'test/components/*.jsx'], // will pass to gulp.src as mocha tests
isparta: false, // use istanbul as default
istanbul: { // will pass to istanbul or isparta
preserveComments: true // required for istanbul 0.4.0+
coverageVariable: '__MY_TEST_COVERAGE__',
exclude: /node_modules|test[0-9]/ // do not instrument these files
},
threshold: 80, // fail the task when coverage lower than this
// default is no threshold
thresholdType: 'functions', // one of 'lines', 'statements', 'functions', 'banches'
// default is 'lines'
transpile: { // this is default whitelist/blacklist for transpilers
babel: {
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)
coffee: {
include: /\.coffee$/,
omitExt: false // if you wanna omit file ext when require(), put an array
}, // of file exts here. Ex: ['.coffee'] (NOT RECOMMENDED)
cjsx: {
include: /\.cjsx$/,
omitExt: false // if you wanna omit file ext when require(), put an array
} // of file exts here. Ex: ['.cjsx'] (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'
},
// Recommend moving this to .babelrc
babel: { // will pass to babel-core
presets: ['es2015', 'react'], // Use proper presets or plugins for your scripts
sourceMap: 'both' // get hints in covarage reports or error stack
},
coffee: { // will pass to coffee.compile
sourceMap: true // true to get hints in HTML coverage reports
},
//optional
cleanup: function () {
// do extra tasks after test done
// EX: clean global.window when test with jsdom
}
}));
var GJC = require('gulp-jsx-coverage');
var jasmine = require('gulp-jasmine');
gulp.task('my_jasmine_tests', function () {
GJC.initIstanbulHook(GJCoptions); // Refer to previous gulp-jsx-coverage options
return gulp.src('test/*.js')
.pipe(jasmine(jasmineOptions))
.on('end', GJC.collectIstanbulCoverage(GJCoptions));
});
gulp.task('your_task_name', require('gulp-jsx-coverage').createTask({
src: ['test/**/*.js', 'test/components/*.jsx'],
isparta: true,
....
});
NOTE: do not support coffee-script when using isparta as coverage tool
git clone https://github.com/zordius/gulp-jsx-coverage.git
cd gulp-jsx-coverage
npm install
npm run mocha
Output:
[13:00:52] Using gulpfile ~/gulp-jsx-coverage/gulpfile.js
[13:00:52] Starting 'default'...
target (tested by test1.js)
✓ should multiply correctly
- should not show coverage info for test1.js
✓ should handle es6 template string correctly
target (tested by test2.jsx)
✓ should multiply correctly
- should not show coverage info for test2.jsx
target (tested by test3.coffee)
✓ should multiply correctly
- should not show coverage info for test3.coffee
4 passing (42ms)
3 pending
----------------|-----------|-----------|-----------|-----------|
File | % Stmts |% Branches | % Funcs | % Lines |
----------------|-----------|-----------|-----------|-----------|
test/ | 80 | 100 | 66.67 | 80 |
target.js | 80 | 100 | 66.67 | 80 |
----------------|-----------|-----------|-----------|-----------|
All files | 80 | 100 | 66.67 | 80 |
----------------|-----------|-----------|-----------|-----------|
[13:00:53] Finished 'default' after 642 ms
0.3.2
0.3.0
Babel upgraded:
API changed:
0.2.0
FAQs
Enable istanbul coverage on ES2015/babel or coffee-script/cjsx files when you do mocha/jasmine tests, also deal with sourceMap for coverage report and stack trace.
The npm package gulp-jsx-coverage receives a total of 66 weekly downloads. As such, gulp-jsx-coverage popularity was classified as not popular.
We found that gulp-jsx-coverage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.