Skip to content

Commit ce576bc

Browse files
committed
Merge pull request #30 from browserstack/worker_timeout
Worker timeout
2 parents b40923a + 1e1852e commit ce576bc

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ If nothing is provided as `preset` **default** is used.
3838
- *test_framework*: Specify test framework which will execute the tests.
3939
We support qunit, jasmine and mocha.
4040

41+
- *timeout*: Specify worker timeout with BrowserStack.
42+
4143
- *browsers*: A list of browsers on which tests are to be run.
4244

4345
A sample configuration file:

bin/runner.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ function launchBrowser(browser, url) {
8888
browser["tunnel_identifier"] = config.tunnelIdentifier;
8989
}
9090

91+
var timeout = parseInt(config.timeout);
92+
if(! isNaN(timeout)) {
93+
browser.timeout = timeout;
94+
} else {
95+
timeout = 300;
96+
}
97+
9198
client.createWorker(browser, function (err, worker) {
9299
if (err || typeof worker !== 'object') {
93100
console.log("Error from BrowserStack: ", err);
@@ -117,19 +124,19 @@ function launchBrowser(browser, url) {
117124
worker.activityTimeout = setTimeout(function () {
118125
if (!worker.acknowledged) {
119126
var subject = "Worker inactive for too long: " + worker.string;
120-
var content = "Worker details:\n" + JSON.stringify(worker, null, 4);
127+
var content = "Worker details:\n" + JSON.stringify(worker.config, null, 4);
121128

122129
utils.alertBrowserStack(subject, content);
123130
}
124-
}, 60 * 1000);
131+
}, timeout * 1000);
125132

126133
setTimeout(function () {
127134
if (workers[key]) {
128135
var subject = "Tests timed out on: " + worker.string;
129-
var content = "Worker details:\n" + JSON.stringify(worker, null, 4);
136+
var content = "Worker details:\n" + JSON.stringify(worker.config, null, 4);
130137
utils.alertBrowserStack(subject, content);
131138
}
132-
}, (config.timeout || 300) * 1000);
139+
}, (timeout * 1000));
133140
}
134141
});
135142
}, 2000);
@@ -145,7 +152,7 @@ var launchBrowsers = function(config, browser) {
145152
});
146153
} else {
147154
var url = 'http://localhost:' + serverPort.toString() + '/' + config.test_path;
148-
launchBrowser(browser,url);
155+
launchBrowser(browser,url);
149156
}
150157
}, 100);
151158
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "git://github.com/browserstack/browserstack-runner.git"
99
},
1010
"dependencies": {
11-
"browserstack": "1.0.1"
11+
"browserstack": "1.0.2"
1212
},
1313
"bin": {
1414
"browserstack-runner": "bin/cli.js"

0 commit comments

Comments
 (0)