@@ -31,7 +31,6 @@ var watch = require('gulp-watch')
3131var batch = require ( 'gulp-batch' )
3232var replace = require ( 'gulp-replace' )
3333var fs = require ( 'fs-extra' )
34- var runSequence = require ( 'run-sequence' )
3534var path = require ( 'path' )
3635var minimist = require ( 'minimist' )
3736var install = require ( 'gulp-install' )
@@ -46,19 +45,13 @@ var transformTools = require('browserify-transform-tools')
4645/**
4746 * Useful to investigate resource leaks in tests. Enable to see active sockets and file handles after the 'test' task.
4847 */
49- var enableActiveNodeHandlesLogging = false
50-
51- gulp . task ( 'default' , [ 'test' ] )
52-
53- gulp . task ( 'browser' , function ( cb ) {
54- runSequence ( 'build-browser-test' , 'build-browser' , cb )
55- } )
48+ const enableActiveNodeHandlesLogging = false
5649
5750/** Build all-in-one files for use in the browser */
58- gulp . task ( 'build-browser' , function ( ) {
59- var browserOutput = 'lib/browser'
51+ gulp . task ( 'build-browser' , async function ( ) {
52+ const browserOutput = 'lib/browser'
6053 // Our app bundler
61- var appBundler = browserify ( {
54+ const appBundler = browserify ( {
6255 entries : [ 'src/index.js' ] ,
6356 cache : { } ,
6457 standalone : 'neo4j' ,
@@ -69,30 +62,29 @@ gulp.task('build-browser', function () {
6962 . bundle ( )
7063
7164 // Un-minified browser package
72- appBundler
65+ await appBundler
7366 . on ( 'error' , gutil . log )
7467 . pipe ( source ( 'neo4j-web.js' ) )
7568 . pipe ( gulp . dest ( browserOutput ) )
7669
77- return appBundler
70+ await appBundler
7871 . on ( 'error' , gutil . log )
7972 . pipe ( source ( 'neo4j-web.min.js' ) )
8073 . pipe ( buffer ( ) )
8174 . pipe ( uglify ( ) )
8275 . pipe ( gulp . dest ( browserOutput ) )
8376} )
8477
85- gulp . task ( 'build-browser-test' , function ( ) {
86- var browserOutput = 'build/browser/'
87- var testFiles = [ ]
78+ gulp . task ( 'build-browser-test' , async function ( ) {
79+ const browserOutput = 'build/browser/'
80+ const testFiles = [ ]
81+
8882 return gulp
89- . src ( [ './test/**/* .test.js' , '!./test/**/node/*.js' ] )
83+ . src ( [ './test/**/!(examples) .test.js' , '!./test/**/node/*.js' ] )
9084 . pipe (
9185 through . obj (
9286 function ( file , enc , cb ) {
93- if ( file . path . indexOf ( 'examples.test.js' ) < 0 ) {
94- testFiles . push ( file . path )
95- }
87+ testFiles . push ( file . path )
9688 cb ( )
9789 } ,
9890 function ( cb ) {
@@ -103,26 +95,20 @@ gulp.task('build-browser-test', function () {
10395 )
10496 )
10597 . pipe (
106- through . obj (
107- function ( testFiles , enc , cb ) {
108- browserify ( {
109- entries : testFiles ,
110- cache : { } ,
111- debug : true
112- } )
113- . transform ( babelifyTransform ( ) )
114- . transform ( browserifyTransformNodeToBrowserRequire ( ) )
115- . bundle ( function ( ) {
116- cb ( )
117- } )
118- . on ( 'error' , gutil . log )
119- . pipe ( source ( 'neo4j-web.test.js' ) )
120- . pipe ( gulp . dest ( browserOutput ) )
121- } ,
122- function ( cb ) {
123- cb ( )
124- }
125- )
98+ through . obj ( function ( testFiles , enc , cb ) {
99+ browserify ( {
100+ entries : testFiles ,
101+ cache : { } ,
102+ debug : true
103+ } )
104+ . transform ( babelifyTransform ( ) )
105+ . transform ( browserifyTransformNodeToBrowserRequire ( ) )
106+ . bundle ( )
107+ . on ( 'error' , gutil . log )
108+ . pipe ( source ( 'neo4j-web.test.js' ) )
109+ . pipe ( gulp . dest ( browserOutput ) )
110+ . on ( 'end' , cb )
111+ } )
126112 )
127113} )
128114
@@ -140,62 +126,40 @@ gulp.task('nodejs', function () {
140126 } )
141127} )
142128
143- gulp . task ( 'all' , function ( cb ) {
144- runSequence ( 'nodejs' , 'browser' , cb )
145- } )
146-
147129// prepares directory for package.test.js
148- gulp . task ( 'install-driver-into-sandbox' , [ 'nodejs' ] , function ( ) {
149- var testDir = path . join ( 'build' , 'sandbox' )
150- fs . emptyDirSync ( testDir )
151-
152- var packageJsonContent = JSON . stringify ( {
153- private : true ,
154- dependencies : {
155- 'neo4j-driver' : __dirname
156- }
157- } )
158-
159- return file ( 'package.json' , packageJsonContent , { src : true } )
160- . pipe ( gulp . dest ( testDir ) )
161- . pipe ( install ( ) )
162- } )
163-
164- gulp . task ( 'test' , function ( cb ) {
165- runSequence (
166- 'run-ts-declaration-tests' ,
167- 'test-nodejs' ,
168- 'test-browser' ,
169- function ( err ) {
170- if ( err ) {
171- var exitCode = 2
172- console . log ( '[FAIL] test task failed - exiting with code ' + exitCode )
173- return process . exit ( exitCode )
130+ gulp . task (
131+ 'install-driver-into-sandbox' ,
132+ gulp . series ( 'nodejs' , function ( ) {
133+ var testDir = path . join ( 'build' , 'sandbox' )
134+ fs . emptyDirSync ( testDir )
135+
136+ var packageJsonContent = JSON . stringify ( {
137+ private : true ,
138+ dependencies : {
139+ 'neo4j-driver' : __dirname
174140 }
175- return cb ( )
176- }
177- )
178- } )
179-
180- gulp . task ( 'test-nodejs' , [ 'install-driver-into-sandbox' ] , function ( ) {
181- return gulp
182- . src ( [ './test/**/*.test.js' , '!./test/**/browser/*.js' ] )
183- . pipe (
184- jasmine ( {
185- includeStackTrace : true ,
186- reporter : newJasmineConsoleReporter ( )
187- } )
188- )
189- . on ( 'end' , logActiveNodeHandles )
190- } )
191-
192- gulp . task ( 'test-browser' , function ( cb ) {
193- runSequence ( 'all' , 'run-browser-test' , cb )
194- } )
141+ } )
195142
196- gulp . task ( 'run-browser-test' , function ( cb ) {
197- runSequence ( 'run-browser-test-firefox' , cb )
198- } )
143+ return file ( 'package.json' , packageJsonContent , { src : true } )
144+ . pipe ( gulp . dest ( testDir ) )
145+ . pipe ( install ( ) )
146+ } )
147+ )
148+
149+ gulp . task (
150+ 'test-nodejs' ,
151+ gulp . series ( 'install-driver-into-sandbox' , function ( ) {
152+ return gulp
153+ . src ( [ './test/**/*.test.js' , '!./test/**/browser/*.js' ] )
154+ . pipe (
155+ jasmine ( {
156+ includeStackTrace : true ,
157+ reporter : newJasmineConsoleReporter ( )
158+ } )
159+ )
160+ . on ( 'end' , logActiveNodeHandles )
161+ } )
162+ )
199163
200164gulp . task ( 'run-browser-test-chrome' , function ( cb ) {
201165 runKarma ( 'chrome' , cb )
@@ -213,6 +177,8 @@ gulp.task('run-browser-test-ie', function (cb) {
213177 runKarma ( 'ie' , cb )
214178} )
215179
180+ gulp . task ( 'run-browser-test' , gulp . series ( 'run-browser-test-firefox' ) )
181+
216182gulp . task ( 'watch' , function ( ) {
217183 return watch (
218184 'src/**/*.js' ,
@@ -222,9 +188,12 @@ gulp.task('watch', function () {
222188 )
223189} )
224190
225- gulp . task ( 'watch-n-test' , [ 'test-nodejs' ] , function ( ) {
226- return gulp . watch ( [ 'src/**/*.js' , 'test/**/*.js' ] , [ 'test-nodejs' ] )
227- } )
191+ gulp . task (
192+ 'watch-n-test' ,
193+ gulp . series ( 'test-nodejs' , function ( ) {
194+ return gulp . watch ( [ 'src/**/*.js' , 'test/**/*.js' ] , [ 'test-nodejs' ] )
195+ } )
196+ )
228197
229198/** Set the project version, controls package.json and version.js */
230199gulp . task ( 'set' , function ( ) {
@@ -295,6 +264,19 @@ gulp.task('run-ts-declaration-tests', function () {
295264 . pipe ( gulp . dest ( 'build/test/types' ) )
296265} )
297266
267+ gulp . task ( 'browser' , gulp . series ( 'build-browser-test' , 'build-browser' ) )
268+
269+ gulp . task ( 'all' , gulp . series ( 'nodejs' , 'browser' ) )
270+
271+ gulp . task ( 'test-browser' , gulp . series ( 'all' , 'run-browser-test' ) )
272+
273+ gulp . task (
274+ 'test' ,
275+ gulp . series ( 'run-ts-declaration-tests' , 'test-nodejs' , 'test-browser' )
276+ )
277+
278+ gulp . task ( 'default' , gulp . series ( 'test' ) )
279+
298280function logActiveNodeHandles ( ) {
299281 if ( enableActiveNodeHandlesLogging ) {
300282 console . log (
@@ -321,8 +303,8 @@ function babelifyTransform () {
321303
322304function babelConfig ( ) {
323305 return {
324- presets : [ ' env'] ,
325- plugins : [ 'transform-runtime' ]
306+ presets : [ [ '@babel/preset- env'] ] ,
307+ plugins : [ '@babel/plugin- transform-runtime' ]
326308 }
327309}
328310
@@ -350,11 +332,7 @@ function browserifyTransformNodeToBrowserRequire () {
350332function runKarma ( browser , cb ) {
351333 new karma . Server (
352334 {
353- configFile : path . join (
354- __dirname ,
355- `/test/browser/karma-${ browser } .conf.js`
356- ) ,
357- singleRun : true
335+ configFile : path . join ( __dirname , `/test/browser/karma-${ browser } .conf.js` )
358336 } ,
359337 function ( exitCode ) {
360338 exitCode ? process . exit ( exitCode ) : cb ( )
0 commit comments