1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", { value: true });
|
8 | const q = require("q");
|
9 | const util = require("util");
|
10 | const logger_1 = require("../logger");
|
11 | const driverProvider_1 = require("./driverProvider");
|
12 | const SauceLabs = require('saucelabs');
|
13 | let logger = new logger_1.Logger('sauce');
|
14 | class Sauce extends driverProvider_1.DriverProvider {
|
15 | constructor(config) {
|
16 | super(config);
|
17 | }
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | updateJob(update) {
|
25 | let deferredArray = this.drivers_.map((driver) => {
|
26 | let deferred = q.defer();
|
27 | driver.getSession().then((session) => {
|
28 | logger.info('SauceLabs results available at http://saucelabs.com/jobs/' + session.getId());
|
29 | this.sauceServer_.updateJob(session.getId(), update, (err) => {
|
30 | if (err) {
|
31 | throw new Error('Error updating Sauce pass/fail status: ' + util.inspect(err));
|
32 | }
|
33 | deferred.resolve();
|
34 | });
|
35 | });
|
36 | return deferred.promise;
|
37 | });
|
38 | return q.all(deferredArray);
|
39 | }
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | setupDriverEnv() {
|
47 | let deferred = q.defer();
|
48 | this.sauceServer_ = new SauceLabs({
|
49 | username: this.config_.sauceUser,
|
50 | password: this.config_.sauceKey,
|
51 | agent: this.config_.sauceAgent,
|
52 | proxy: this.config_.sauceProxy
|
53 | });
|
54 | this.config_.capabilities['username'] = this.config_.sauceUser;
|
55 | this.config_.capabilities['accessKey'] = this.config_.sauceKey;
|
56 | this.config_.capabilities['build'] = this.config_.sauceBuild;
|
57 | let protocol = this.config_.sauceSeleniumUseHttp ? 'http://' : 'https://';
|
58 | let auth = protocol + this.config_.sauceUser + ':' + this.config_.sauceKey + '@';
|
59 | this.config_.seleniumAddress = auth +
|
60 | (this.config_.sauceSeleniumAddress ? this.config_.sauceSeleniumAddress :
|
61 | 'ondemand.saucelabs.com:443/wd/hub');
|
62 |
|
63 |
|
64 | if (this.config_.capabilities.name && this.config_.capabilities.shardTestFiles) {
|
65 | this.config_.capabilities.name +=
|
66 | (':' + this.config_.specs.toString().replace(/^.*[\\\/]/, ''));
|
67 | }
|
68 | logger.info('Using SauceLabs selenium server at ' +
|
69 | this.config_.seleniumAddress.replace(/\/\/.+@/, '//'));
|
70 | deferred.resolve();
|
71 | return deferred.promise;
|
72 | }
|
73 | }
|
74 | exports.Sauce = Sauce;
|
75 |
|
\ | No newline at end of file |