forked from wix-incubator/wix-gruntfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grunt-protractor.js
57 lines (52 loc) · 1.57 KB
/
grunt-protractor.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
'use strict';
var spawn = require('child_process').spawn;
var grunt = require('grunt');
module.exports = {
updateWebdriver: function (done) {
var p = spawn('node', ['node_modules/protractor/bin/webdriver-manager', 'update']);
p.stdout.pipe(process.stdout);
p.stderr.pipe(process.stderr);
p.on('exit', function (code) {
if (code !== 0) {
grunt.fail.warn('Webdriver failed to update');
}
done();
});
},
startProtractor: function (config, done) {
var sauceUser = grunt.option('sauceUser');
var sauceKey = grunt.option('sauceKey');
var tunnelIdentifier = grunt.option('capabilities.tunnel-identifier');
var sauceBuild = grunt.option('capabilities.build');
var browser = grunt.option('browser');
var specs = grunt.option('specs');
var args = ['node_modules/protractor/bin/protractor', config];
if (sauceUser) {
args.push('--sauceUser=' + sauceUser);
}
if (sauceKey) {
args.push('--sauceKey=' + sauceKey);
}
if (tunnelIdentifier) {
args.push('--capabilities.tunnel-identifier=' + tunnelIdentifier);
}
if (sauceBuild) {
args.push('--capabilities.build=' + sauceBuild);
}
if (specs) {
args.push('--specs=' + specs);
}
if (browser) {
args.push('--browser=' + browser);
}
var p = spawn('node', args);
p.stdout.pipe(process.stdout);
p.stderr.pipe(process.stderr);
p.on('exit', function (code) {
if (code !== 0) {
grunt.fail.warn('Protractor test(s) failed. Exit code: ' + code);
}
done();
});
},
};