SBoudrias/gulp-istanbul — 184★ trên GitHub (JavaScript). Istanbul unit test coverage plugin for gulp.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
var istanbul = require('gulp-istanbul');
// We'll use mocha in this example, but any test framework will work
var mocha = require('gulp-mocha');
gulp.task('pre-test', function () {
return gulp.src(['lib/**/*.js'])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['pre-test'], function () {
return gulp.src(['test/*.js'])
.pipe(mocha())
// Creating the reports after tests ran
.pipe(istanbul.writeReports())
// Enforce a coverage of at least 90%
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
});
Note: Version 4.x.x of gulp-mocha is not supported (see issue #115 for details). In this example, you should use gulp-mocha version 3.0.1 for the time being.
Browser testing
For browser testing, you'll need to write the files covered by istanbul in a directory from where you'll serve these files to the browser running the test. You'll also need a way to extract the value of the coverage variable after the test have runned in the browser.
Browser testing is hard. If you're not sure what to do, then I suggest you take a look at Karma test runner - it has built-in coverage using Istanbul.
var istanbul = require('gulp-istanbul');
gulp.task('pre-test', function () {
return gulp.src(['lib/**/*.js'])
// Covering files
.pipe(istanbul())
// Write the covered files to a temporary directory
.pipe(gulp.dest('test-tmp/'));
});
gulp.task('test', ['pre-test'], function () {
// Make sure your tests files are requiring files from the
// test-tmp/ directory
return gulp.src(['test/*.js'])
.pipe(testFramework())
// Creating the reports after tests ran
.pipe(istanbul.writeReports());
});
Source Maps
gulp-istanbul supports gulp-sourcemaps when instrumenting:
gulp.task('pre-test', function () {
return gulp.src(['lib/**/*.js'])
// optionally load existing source maps
.pipe(sourcemaps.init())
// Covering files
.pipe(istanbul())
.pipe(sourcemaps.write('.'))
// Write the covered files to a temporary directory
.pipe(gulp.dest('test-tmp/'));
});
watermarks can be used to confgure the color of the HTML report.
Default colors are.. RED: below 50% coverage, YELLOW: 50-80% coverage, GREEN: above 80%
coverageVariable
Type: String (optional)
Default: '$$cov_' + new Date().getTime() + '$$'
The global variable istanbul uses to store coverage
See also:
istanbul coverageVariable
SanboxedModule
istanbul.enforceThresholds(opt)
Checks coverage against minimum acceptable thresholds. Fails the build if any of the thresholds are not met.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/SBoudrias/gulp-istanbul là nguồn chính thức.
SBoudrias/gulp-istanbul có phải mã nguồn mở không?
Có — SBoudrias/gulp-istanbul phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/SBoudrias/gulp-istanbul.
SBoudrias/gulp-istanbul có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho SBoudrias/gulp-istanbul. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
SBoudrias/gulp-istanbul dùng license gì?
SBoudrias/gulp-istanbul phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
SBoudrias/gulp-istanbul là gì?
SBoudrias/gulp-istanbul (SBoudrias/gulp-istanbul) là dự án JavaScript trên GitHub. Theo mô tả gốc: Istanbul unit test coverage plugin for gulp.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc gulp-istanbul có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về gulp-istanbul.