-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
116 lines (101 loc) · 3.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
var gulp = require('gulp-help')(require('gulp'));
// jamine runner.
var jasmine = require('gulp-jasmine');
// the default task.
gulp.task('default', ['help']);
gulp.task('hello', 'Hello Gulp World!', function() {
// place code for your default task here
console.log('Hello Gulp World!');
});
// using the express to serve static files.
var gls = require('gulp-live-server');
// the simplest express static server.
//var liveServer = gls.static('.', 8900);
// using a simple javascript file for express server.
var liveServer = gls.new('test/express.js');
gulp.task('express-app', function() {
liveServer.start();
});
// testing the webdriverio and selenium standalone
var webdirverSingle = require('gulp-webdriver');
// using jasmine as the test framework.
gulp.task('test:webdriver:jasmine',
'Execute all test cases',
['selenium'], function() {
return gulp.src('test/wdio.conf.jasmine.js').
pipe(webdirverSingle({
//logLevel: 'verbose',
//logLevel: 'command',
logLevel: 'silent',
waitforTimeout: 12345,
// only for testing purposes
cucumberOpts: {
require: 'nothing'
},
reporter: 'spec'
})).once('end', function() {
// shutdown the selenium standalone server
selenium.child.kill();
});
});
/**
* create separate task for testing on windows.
* Windows environment need some special steps...
*/
gulp.task('wintest:webdriver:jasmine',
'Execute all test cases on Windows',
['selenium-skip-install'], function() {
return gulp.src('test/wdio.win.conf.jasmine.js').
pipe(webdirverSingle({
// we could overwrite the options set in the config file.
// or add new options here.
cucumberOpts: {
require: 'nothing'
},
reporter: 'spec'
})).once('end', function() {
// shutdown the selenium standalone server
selenium.child.kill();
});
});
var selenium = require('selenium-standalone');
gulp.task('selenium', 'Install and start selenium server',
function (done) {
selenium.install({
logger: function (message) {
console.log(message);
}
}, function (err) {
if (err) return done(err);
selenium.start({
spawnOptions: {
stdio: 'inherit'
}
}, function (err, child) {
if (err) return done(err);
selenium.child = child;
done();
});
});
});
/**
* the task to start selenium directly.
* in some internal network behind firewall, it is hard to automatically
* donwload selenium and its drivers.
* User need manually download everything and put to the proper folder.
* This task will load selenium once the manual steps are done.
*/
gulp.task('selenium-skip-install', 'Start selenium server',
function (done) {
selenium.start({
spawnOptions: {
// set stdio to inherit to show details logging message from
// selenium server.
//stdio: 'inherit'
}
}, function (err, child) {
if (err) return done(err);
selenium.child = child;
done();
});
});