Gulp and phantomjs -


i'm trying run automatic test gulp. works fine don't how close phantomjs after codeception has finished. gulp.js file looks this

var gulp = require('gulp'); var connect = require('gulp-connect-php'); var shell = require('gulp-shell'); var codecept = require('gulp-codeception');  gulp.task('webserver', function() {      connect.server({       base : './public'     }); });  gulp.task('phantom', shell.task(['phantomjs.exe --webdriver=4444']));  gulp.task('codecept', function() {     gulp.src('./tests/*.php').pipe(codecept()); });  gulp.task('tests', ['phantom', 'codecept']); 

is there way stop phantom after tests done or better way lunch phantom?

this worked me under phantomjs v2.0:

var gulp = require('gulp'); var gutil = require('gulp-util'); var codecept = require('gulp-codeception');  gulp.task('codecept', function(done) {    runinphantomjs(function() {        return gulp.src('./tests/*.php').pipe(codecept());    }, done); });  function runinphantomjs(fn, done) {     var args = [ '--webdriver=4444' ],     phantomjsprocess = childprocess.spawn('phantomjs', args),     completed = false;      phantomjsprocess.stdout.on('data', function(data) {         if (data.tostring().indexof('running on port') >= 0) {             fn().on('end', function() {                 completed = true;                 phantomjsprocess.kill();             });         }     });     phantomjsprocess.stderr.on('data', function(data) {         gutil.log(gutil.colors.red(data));     });     phantomjsprocess.on('close', function(code) {         if (code && !completed) {             return done(new error('phantomjs failed code: ' + code + '\n' +                'check port 4444 free , there no other ' +                'instances of phantomjs running.'));         }         done();     }); } 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -