forked from wix-incubator/wix-gruntfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrunt-protractor.js
47 lines (42 loc) · 1.41 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
'use strict';
var spawn = require('child_process').spawn;
var grunt = require('grunt');
var protractorDir = require.resolve('protractor/bin/elementexplorer.js').replace('elementexplorer.js', '');
module.exports = {
updateWebdriver: function (done) {
var p = spawn('node', [protractorDir + '/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 allowedOptions = ['sauceUser', 'sauceKey', 'capabilities.tunnel-identifier',
'capabilities.build', 'browser', 'specs', 'baseUrl'];
allowedOptions.forEach(function (option) {
var value = grunt.option(option);
if (value) {
config[option] = value;
}
});
var args = [protractorDir + '/protractor', config.configFile];
args = args.concat(Object.keys(config).filter(function (key) {
return key !== 'configFile';
}).map(function (key) {
return '--' + key + '=' + config[key];
}));
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();
});
}
};