
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
gulp-jsx-coverage
Advanced tools
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.
Enable istanbul coverage on ES2015/babel files when you do mocha/jasmine tests, also deal with sourceMap for stack trace....as gulp task.
ORIGINAL CODE/LINE in coverage reports
ORIGINAL CODE/LINE in stack traces
For Mocha tests:
npm install gulp gulp-jsx-coverage gulp-mocha babel-plugin-istanbul --save-dev
For Jasmine tests:
npm install gulp gulp-jsx-coverage gulp-jasmine babel-plugin-istanbul --save-dev
Configure your .babelrc and install proper presets or plugins.
Here is a .babelrc example:
{
presets: ['es2015', 'react']
}
And then:
npm install babel-preset-es2015 babel-preset-react
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: gulp your_task_name
require('file.jsx')
.gulp.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|test[0-9]/ // 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
}
}));
var 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
});
git clone https://github.com/zordius/gulp-jsx-coverage.git
cd gulp-jsx-coverage
npm install
npm run mocha
OUTPUT:
~/gulp-jsx-coverage master>npm run mocha
> gulp-jsx-coverage@0.3.8 mocha /Users/zordius/gulp-jsx-coverage
> gulp mocha_tests
[11:50:14] Using gulpfile ~/gulp-jsx-coverage/gulpfile.js
[11:50:14] Starting 'mocha_tests'...
target (tested by test1.js)
✓ should multiply correctly
- should not show coverage info for test1.js
✓ should handle es2015 template string correctly
target (tested by test2.jsx)
✓ should multiply correctly (77ms)
- should not show coverage info for test2.jsx
1) should exception and failed
Component.jsx (tested by test2.jsx)
✓ should render Hello World
4 passing (104ms)
2 pending
1 failing
1) target (tested by test2.jsx) should exception and failed:
TypeError: "hohoho
this is
multi line
error!".notAFunction is not a function
at Context.<anonymous> (test2.jsx:34:10)
[11:50:16] 'mocha_tests' errored after 1.86 s
[11:50:16] Error in plugin 'gulp-mocha'
Message:
1 test failed.
---------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
---------------|----------|----------|----------|----------|----------------|
All files | 90.48 | 100 | 75 | 90.48 | |
Component.jsx | 75 | 100 | 50 | 75 | 5 |
target.js | 80 | 100 | 66.67 | 80 | 8 |
testlib.js | 100 | 100 | 100 | 100 | |
---------------|----------|----------|----------|----------|----------------|
0.4.0
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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.