node.js - Gulp: Wait for express server to start before running tests -
i'm pretty new node. built sample express app , wrote bdd tests using cucumber.js. automate tests using gulp when run tests first start express app and, once server up, run through tests. however, tests run before server , therefore fail. there way wait (using gulp) server start , run tests?
i'm using gulp-cucumber , gulp-express here (somewhat hidden gulp-load-plugins).
my gulpfile (partial):
var gulp = require('gulp'), plugins = require('gulp-load-plugins')(); gulp.task('server', function () { plugins.express.run(['bin/www']); }); gulp.task('cucumber', ['server'], function() { return gulp.src('features/*').pipe(plugins.cucumber({ 'steps': 'features/steps/*.steps.js', 'support': 'features/support/*.js' })); }); gulp.task('test', ['server', 'cucumber']);
i have use solution - https://www.npmjs.com/package/run-sequence
var gulp = require('gulp'), plugins = require('gulp-load-plugins')(), runsequence = require('run-sequence'); gulp.task('server', function () { plugins.express.run(['bin/www']); }); gulp.task('cucumber', function() { return gulp.src('features/*').pipe(plugins.cucumber({ 'steps': 'features/steps/*.steps.js', 'support': 'features/support/*.js' })); }); gulp.task('test', function(){ runsequence('server', 'cucumber'); });
Comments
Post a Comment