Skip to content

Commit

Permalink
FAB-10434 NodeSDK - use nyc for code coverage
Browse files Browse the repository at this point in the history
Add (istanbuljs) nyc package for code coverage in order to test async functions
Remove gulp-istanbul because it throws error for async functions

Change-Id: I07a24dc3972fb011ba66460e6148f5f487cc5b2c
Signed-off-by: wenjian <[email protected]>
  • Loading branch information
wenjianqiao committed May 29, 2018
1 parent daaf7b7 commit a851829
Show file tree
Hide file tree
Showing 4 changed files with 2,770 additions and 407 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ test/fixtures/src/github.com/example_cc/junk.go
*.heapsnapshot
.vscode
.idea
.nyc_output/*
test/typescript/**/*.js
test/typescript/**/*.js.map
27 changes: 13 additions & 14 deletions build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
var gulp = require('gulp');
var tape = require('gulp-tape');
var tapColorize = require('tap-colorize');
var istanbul = require('gulp-istanbul');
var addsrc = require('gulp-add-src');

var fs = require('fs-extra');
Expand Down Expand Up @@ -67,9 +66,7 @@ gulp.task('pre-test', function() {
'fabric-ca-client/lib/helper.js',
'fabric-ca-client/lib/IdentityService.js',
'fabric-ca-client/lib/AffiliationService.js',
])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
]);
});

gulp.task('clean-up', function() {
Expand Down Expand Up @@ -106,7 +103,17 @@ gulp.task('compile', shell.task([
ignoreErrors: false // once compile failed, throw error
}));

gulp.task('test', ['clean-up', 'lint', 'pre-test', 'compile', 'docker-ready', 'ca'], function() {
// Use nyc instead of gulp-istanbul to generate coverage report
// Cannot use gulp-istabul because it throws "unexpected identifier" for async/await functions
gulp.task('test', shell.task(
'./node_modules/nyc/bin/nyc.js gulp run-test'
));

gulp.task('test-headless', shell.task(
'./node_modules/nyc/bin/nyc.js gulp run-test-headless'
));

gulp.task('run-test', ['clean-up', 'lint', 'pre-test', 'compile', 'docker-ready', 'ca'], function() {
// use individual tests to control the sequence they get executed
// first run the ca-tests that tests all the member registration
// and enrollment scenarios (good and bad calls). Then the rest
Expand Down Expand Up @@ -156,14 +163,10 @@ gulp.task('test', ['clean-up', 'lint', 'pre-test', 'compile', 'docker-ready', 'c
))
.pipe(tape({
reporter: tapColorize()
}))
.pipe(istanbul.writeReports({
reporters: ['lcov', 'json', 'text',
'text-summary', 'cobertura']
}));
});

gulp.task('test-headless', ['clean-up', 'lint', 'pre-test', 'ca'], function() {
gulp.task('run-test-headless', ['clean-up', 'lint', 'pre-test', 'ca'], function() {
// this is needed to avoid a problem in tape-promise with adding
// too many listeners
// to the "unhandledRejection" event
Expand All @@ -180,10 +183,6 @@ gulp.task('test-headless', ['clean-up', 'lint', 'pre-test', 'ca'], function() {
))
.pipe(tape({
reporter: tapColorize()
}))
.pipe(istanbul.writeReports({
reporters: ['lcov', 'json', 'text',
'text-summary', 'cobertura']
}));
});

Expand Down
Loading

0 comments on commit a851829

Please sign in to comment.