Skip to content

Commit 7561403

Browse files
committed
2 parents b0e970b + 801ab2b commit 7561403

20 files changed

+242
-6
lines changed

.gitmodules

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[submodule "tests/external-repos/underscorejs"]
2+
path = tests/external-repos/underscorejs
3+
url = https://github.com/browserstack/underscore
4+
[submodule "tests/external-repos/Modernizr"]
5+
path = tests/external-repos/Modernizr
6+
url = https://github.com/browserstack/Modernizr
7+
[submodule "tests/external-repos/url.js"]
8+
path = tests/external-repos/url.js
9+
url = https://github.com/browserstack/url.js.git
10+
[submodule "tests/external-repos/mout"]
11+
path = tests/external-repos/mout
12+
url = https://github.com/browserstack/mout
13+
[submodule "tests/external-repos/Comparatorsjs"]
14+
path = tests/external-repos/Comparatorsjs
15+
url = https://github.com/browserstack/Comparators.js

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
A command line interface to run browser tests over BrowserStack.
22

33
## Install
4-
Go to the `browserstack-runner` directory.
4+
Go to the `browserstack-runner` directory.
55
Install browserstack-runner
66

77
npm -g install
@@ -36,7 +36,7 @@ If nothing is provided as `preset` **default** is used.
3636
in a browser.
3737

3838
- *test_framework*: Specify test framework which will execute the tests.
39-
We support qunit, jasmine and mocha.
39+
We support qunit, jasmine, jasmine 2.0 and mocha.
4040

4141
- *timeout*: Specify worker timeout with BrowserStack.
4242

@@ -48,7 +48,7 @@ A sample configuration file:
4848
{
4949
"username": "<username>",
5050
"key": "<key>",
51-
"test_framework": "qunit/jasmine/mocha",
51+
"test_framework": "qunit/jasmine/jasmine2/mocha",
5252
"test_path": ["relative/path/to/test/page1", "relative/path/to/test/page2"],
5353
"browsers": [{
5454
"browser": "firefox",

bin/cli.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ function runTests() {
290290
});
291291
});
292292
});
293+
} else {
294+
launchServer();
293295
}
294296
}
295297

lib/_patch/browserstack.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
console.log = function (arguments) {
4343
post('/_log/', arguments, function () {});
4444
};
45+
console.warn = function (arguments) {
46+
post('/_log/', arguments, function () {});
47+
};
4548

4649
BrowserStack.post = post;
4750
BrowserStack.getParameterByName = getParameterByName;

lib/_patch/jasmine2-plugin.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(function() {
2+
var checker = setInterval(function() {
3+
if (!jasmine.running) {
4+
var results = {};
5+
var specs = jsApiReporter.specs();
6+
results.runtime = jsApiReporter.executionTime();
7+
results.total = 0;
8+
results.passed = 0;
9+
results.failed = 0;
10+
results.tracebacks = [];
11+
12+
for (var spec in specs) {
13+
if (specs[spec].status === 'passed') {
14+
results.passed++;
15+
} else {
16+
results.tracebacks.push(specs[spec].description);
17+
results.failed = true;
18+
}
19+
}
20+
21+
results.total = results.passed + results.failed;
22+
results.url = window.location.pathname;
23+
BrowserStack.post('/_report', results, function(){});
24+
}
25+
clearInterval(checker);
26+
}, 1000);
27+
})();
28+

lib/server.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,19 @@ exports.Server = function Server(bsClient, workers) {
7979
framework_scripts = {
8080
'qunit': ['qunit-plugin.js'],
8181
'jasmine': ['jasmine-jsreporter.js', 'jasmine-plugin.js'],
82+
'jasmine2': ['jasmine2-plugin.js'],
8283
'mocha': ['mocha-plugin.js']
8384
};
8485

85-
if (mimeType === 'text/html') {
86+
var filePath = path.relative(process.cwd(), filename);
87+
var pathMatches;
88+
89+
if (typeof config.test_path === 'object') {
90+
pathMatches = (config.test_path.indexOf(filePath) != -1);
91+
} else {
92+
pathMatches = (filePath == config.test_path);
93+
}
94+
if (pathMatches && mimeType === 'text/html') {
8695
var matcher = /(.*)<\/head>/;
8796
var patch = "$1";
8897
scripts.forEach(function(script) {
@@ -95,6 +104,10 @@ exports.Server = function Server(bsClient, workers) {
95104
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
96105
});
97106
patch += "<script type='text/javascript'>jasmine.getEnv().addReporter(new jasmine.JSReporter());</script>\n";
107+
} else if (config['test_framework'] && config['test_framework'] == "jasmine2") {
108+
framework_scripts['jasmine2'].forEach(function(script) {
109+
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
110+
});
98111
} else if (config['test_framework'] && config['test_framework'] == "mocha") {
99112
framework_scripts['mocha'].forEach(function(script) {
100113
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";

lib/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ var uuid = function uuidGenerator() {
2626
};
2727

2828
var browserString = function browserString(config) {
29-
return config.os + ' ' + config.os_version + ', ' + (config.browser == 'ie' ? 'IE' : titleCase(config.browser || config.device)) + ' ' + (config.browser_version || config.device);
29+
var os_details = config.os + ' ' + config.os_version;
30+
if (config.browser) {
31+
return os_details + ', ' + (config.browser == 'ie' ? 'Internet Explorer' : titleCase(config.browser)) + ' ' + config.browser_version;
32+
} else {
33+
return os_details + (config.device ? (', ' + config.device) : "");
34+
}
3035
};
3136

3237
var objectSize = function objectSize(obj) {

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "browserstack-runner",
33
"description": "A command line interface to run browser tests over BrowserStack",
4-
"version": "0.1.11",
4+
"version": "0.1.13",
55
"homepage": "https://github.com/browserstack/browserstack-runner",
66
"repository": {
77
"type": "git",
@@ -12,6 +12,9 @@
1212
"chalk": "0.4.0",
1313
"tunnel": "0.0.3"
1414
},
15+
"devDependencies": {
16+
"mocha": "~1.15.1"
17+
},
1518
"licenses": [
1619
{
1720
"type": "MIT",

tests/conf/Comparatorsjs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"username": "BROWSERSTACK_USERNAME",
3+
"key": "BROWSERSTACK_KEY",
4+
"test_path": "comparators.spec-runner.html",
5+
"test_framework": "jasmine2",
6+
"debug": true,
7+
"browsers": [
8+
]
9+
}

tests/conf/Modernizr.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"username": "BROWSERSTACK_USERNAME",
3+
"key": "BROWSERSTACK_KEY",
4+
"test_path": "test/index.html",
5+
"debug": true,
6+
"browsers": [
7+
]
8+
}

0 commit comments

Comments
 (0)