Skip to content

Commit

Permalink
fix: generate tunnel id only if starting sauce connect
Browse files Browse the repository at this point in the history
When tunnelIdentifier is not explicitly configured, generate a random id only if starting sauce connect.

When the developer does not want to start sauce connect, it's more likely he is reusing some already running instance of sauce connect and it's more likely this instance is not using any tunnel id.
  • Loading branch information
vojtajina committed Jul 2, 2013
1 parent a0f9f2c commit fb138bc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,20 @@ var SauceLabsBrowser = function(id, args, sauceConnect, /* config.sauceLabs */ c

var username = process.env.SAUCE_USERNAME || args.username || config.username;
var accessKey = process.env.SAUCE_ACCESS_KEY || args.accessKey || config.accessKey;
var tunnelIdentifier = args.tunnelIdentifier || config.tunnelIdentifier || 'karma' + Math.round(new Date().getTime() / 1000);
var tunnelIdentifier = args.tunnelIdentifier || config.tunnelIdentifier;
var browserName = args.browserName + (args.version ? ' ' + args.version : '') +
(args.platform ? ' (' + args.platform + ')' : '') + ' on SauceLabs';
var startConnect = config.startConnect !== false;
var log = logger.create('launcher.sauce');

var self = this;
var driver;
var captured = false;

if (startConnect && !tunnelIdentifier) {
tunnelIdentifier = 'karma' + Math.round(new Date().getTime() / 1000);
}

this.id = id;
this.name = browserName;

Expand Down Expand Up @@ -116,7 +121,7 @@ var SauceLabsBrowser = function(id, args, sauceConnect, /* config.sauceLabs */ c
};

this.start = function(url) {
if (config.startConnect !== false) {
if (startConnect) {
sauceConnect.start(username, accessKey, tunnelIdentifier).then(function() {
start(url);
});
Expand Down

0 comments on commit fb138bc

Please sign in to comment.