forked from dustyjuhl/e2e-testing-seed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
43 lines (38 loc) · 1.14 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
var gulp = require('gulp');
var path = require('path');
var selenium = require('selenium-standalone');
var spawn = require('child_process').spawn;
var seleniumProcess = null; // track the selenium process
gulp.task('default', ['test']);
gulp.task('selenium:install', function(done) {
selenium.install(done);
});
gulp.task('selenium:start', ['selenium:install'], function(done) {
selenium.start(function(err, process) {
seleniumProcess = err ? null : process;
done();
});
});
gulp.task('test', ['selenium:start'], function(done) {
var cmd = process.platform === 'win32' ? 'nightwatch.cmd' : 'nightwatch';
var fullCmd = path.join('node_modules', '.bin', cmd);
var args = ['--config', 'tests/nightwatch.conf.js'];
if (process.env.env) {
args.push('--env', process.env.env);
}
var nw = spawn(fullCmd, args);
nw.stdout.on('data', function(data) {
console.log(data.toString());
});
nw.stderr.on('data', function(data) {
console.log(data.toString());
});
nw.on('close', function(code) {
if (seleniumProcess) {
seleniumProcess.kill();
seleniumProcess = null;
}
done();
});
nw.on('error', done);
});