javascript - Reloading cucumber.js steps with gulp-watch and gulp-develop-server -


i'm trying use following gulpfile.js in order watch changes, restart server, , re-run tests (cucumber.js). changing cucumber spec, or file in application both trigger process. however, updated content of specs ignored! it's spec cached. how can ensure latest specs executed?

file content:

"use strict"; var gulp = require( "gulp" ); var cucumber = require( "gulp-cucumber" ); var watch = require( "gulp-watch" ); var server = require( 'gulp-develop-server' );  gulp.task( "cukes", function( done ) {      return gulp.src( "specs/**/*.feature" ).pipe( cucumber( {          "steps" : "specs/steps/**/*.js,support/*_hooks.js",         "format" : "pretty"      } ) );  } );   gulp.task( "test", [ "server:start", "cukes" ] );  gulp.task( "server:start", function() {      server.listen( { path: "./index.js" } );  } );  gulp.task( "watch", [ "server:start" ], function() {      watch( [ "lib/**/*", "specs/**/*" ], function() {          server.restart( function() {              settimeout( function() { gulp.start( "cukes" ); }, 500 );          } );      } );  } ); 

node modules cached in require.cache, need reset cache not include cucumber requires. can saving object.keys(require.cache) before calling watch(), , deleting new keys require.cache before starting "cukes" task. should work:

gulp.task( "watch", [ "server:start" ], function() { var originalkeys = object.keys(require.cache); watch( [ "lib/**/*", "specs/**/*" ], function() { server.restart( function() { var newkeys = object.keys(require.cache); while (newkeys.length > originalkeys.length) { delete require.cache[newkeys.pop()]; } settimeout( function() { gulp.start( "cukes" ); }, 500 ); } ); } ); } );

(it idea add gulp-cucumber via pull request.)


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -