-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
67 lines (56 loc) · 1.96 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var istanbul = require( 'gulp-istanbul' );
var gulp = require( 'gulp' );
var mocha = require( 'gulp-mocha' );
var open = require( 'open' ); //jshint ignore : line
function cover( done ) {
gulp.src( [ './src/**/*.js' ] )
.pipe( istanbul() )
.pipe( istanbul.hookRequire() )
.on( 'finish', function() {
done( runSpecs() );
} );
}
function runSpecs() { // jshint ignore : line
return gulp.src( [ './spec/behavior/users.spec.js', './spec/behavior/actions.spec.js', './spec/behavior/auth.spec.js', './spec/behavior/roles.spec.js', './spec/integration/autohost.spec.js' ], { read: false } )
.pipe( mocha( { reporter: 'spec' } ) );
}
function writeReport( cb, openBrowser, tests ) {
tests
.on( 'error', function( e ) {
console.log( 'error occurred during testing', e.stack );
} )
.pipe( istanbul.writeReports() )
.on( 'end', function() {
if ( openBrowser ) {
open( './coverage/lcov-report/index.html' );
}
cb();
} );
}
gulp.task( 'continuous-coverage', function( cb ) {
cover( writeReport.bind( undefined, cb, false ) );
} );
gulp.task( 'continuous-test', function() {
return runSpecs()
.on( 'end', function() {
console.log( process._getActiveRequests() );
console.log( process._getActiveHandles() );
} );
} );
gulp.task( 'coverage', function( cb ) {
cover( writeReport.bind( undefined, cb, true ) );
} );
gulp.task( 'coverage-watch', function() {
gulp.watch( [ './src/**/*', './spec/**/*.spec.js' ], [ 'continuous-coverage' ] );
} );
gulp.task( 'test', function() {
return runSpecs()
.on( 'end', process.exit.bind( process, 0 ) )
.on( 'error', process.exit.bind( process, 1 ) );
} );
gulp.task( 'test-watch', function() {
gulp.watch( [ './src/**/*', './spec/**/*.spec.js' ], [ 'continuous-test' ] );
} );
gulp.task( 'default', [ 'continuous-coverage', 'coverage-watch' ], function() {} );
// gulp.task( 'specs', [ 'continuous-test', 'test-watch' ], function() {} );
gulp.task( 'specs', [ 'continuous-test', 'test-watch' ], function() {} );