Open demisx opened 9 years ago
As a workaround just fire the kill
event to the webserver to end it.
How does one fire the kill
event?
It is difficult to fire kill
event if the setup runs several tasks in a row, I don't know how I can get hold of the stream
:
var runSequence = require('run-sequence');
gulp.task('test-e2e', function(cb) {
runSequence(
'build-site',
'webserver-start', // how can I get this task's stream so I can call 'kill' on it?
'protractor-test',
cb);
});
Thank you @demisx for pointing out the gulp-exit
. It does the work, although I am not sure I use it as intended:
var runSequence = require('run-sequence');
gulp.task('test-e2e', function(cb) {
runSequence(
'build-site',
'webserver-start', // how can I get this task's stream so I can call 'kill' on it?
'protractor-test',
function() {
gulp.src("").pipe(exit());
cb();
);
});
@mickeyvip had one flaw for me - it sometimes did not close the webserver when protractor
failed some tests. On dev machine it is not a problem but it resulted in very long builds on CI (travis), since the build basically had to time-out and get killed.
Instead, I have found a completely different approach based on https://github.com/angular/angular-seed/.
SO answer: http://stackoverflow.com/a/41983565/1549135
Let npm start a webserver for you package.json
"scripts": {
"pretest": "npm install",
"test": "(npm start > /dev/null &) && (gulp protractor)",
"start": "http-server -a localhost -p 8000 -c-1 ./"
},
Use gulp-angular-protractor
gulpfile.js
gulp.task('protractor', function (callback) {
gulp
.src('tests/*.js')
.pipe(gulpProtractorAngular({
'configFile': 'protractor.conf.js',
'debug': false,
'autoStartStopServer': true,
'verbose': false,
'webDriverUpdate': {
'browsers': ['ie', 'chrome']
}
}))
.on('error', function (e) {
console.log(e);
})
.on('end', callback);
});
And it works all good :smiley:
See the above in action in GitHub project: https://github.com/atais/angular-eonasdan-datetimepicker
Hi. I currently start the connect server from
protractor
task like this:The problem is that the
protractor
task never ends. Is it possible to enable a single run mode, so it exits the task whengulp protractor
task is finished?