-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (58 loc) · 2.15 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Note, fo a cross-platform way to kill node processes, needed to end the Gulp tasks
// if you want to use Gulp on your CI server, see
// http://krasimirtsonev.com/blog/article/Nodejs-managing-child-processes-starting-stopping-exec-spawn.
var exec = require('child_process').exec;
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var paths = {
js: ['app/**/*.js', 'features/**/*.js', 'page-objects/**/*.js']
};
gulp.task('lint', function() {
return gulp.src(paths.js)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('watch', function() {
gulp.watch(paths.js, ['lint', 'protractor-watch']);
});
gulp.task('serve-app', function(cb) {
exec('node server.js', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
});
// This task doesn't complete, but we do want a delay so that the server can start.
// Nb, th right way to do this is to create/use a plugin with events, have a look
// at gulp-express with express.run(), express.stop() for implementation ideas.
setTimeout(cb, 1500);
});
gulp.task('webdriver-update', function(cb) {
exec('node node_modules/protractor/bin/webdriver-manager update', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('webdriver-start', function(cb) {
exec('node node_modules/protractor/bin/webdriver-manager start', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
});
// This task doesn't complete, but we do want a delay so that the server can start.
// Nb, the right way to do this is to create/use a plugin with events.
setTimeout(cb, 1500);
});
gulp.task('protractor-start', ['serve-app', 'webdriver-start'], function(cb) {
protractorTest(cb);
});
gulp.task('protractor-watch', function(cb) {
protractorTest(cb);
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['lint', 'protractor-start', 'watch']);
// Helper functions
function protractorTest(cb) {
exec('node node_modules/protractor/bin/protractor ./protractor-conf.js', function (err, stdout, stderr) {
console.log(stdout);
cb();
});
}