Skip to content

Commit 0366d81

Browse files
authored
Merge pull request #4 from browserstack/spec_v1
Spec v1
2 parents 8efc941 + c9072ca commit 0366d81

11 files changed

Lines changed: 111 additions & 64 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
local.log
3+
testem.log

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
node_js:
3+
- "4.3"
4+
- "4.0"
5+
- "0.12"
6+
- "0.10"
7+
8+
before_install:
9+
- true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==`
10+

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1-
Testem with BrowserStack
2-
========================
1+
# testem-browserstack
2+
[Testem](https://github.com/testem/testem) Integration with BrowserStack.
33

4-
Run your tests on various browsers hosted on Browserstack!
4+
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)
55

6-
Instructions
7-
------------
6+
## Setup
7+
* Clone the repo
8+
* Install dependencies `npm install`
9+
* Update `testem.json` file with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
810

9-
1. Get a [BrowserStack](browserstack.com) account.
10-
2. For BrowserStack Authentication export the environment variables for the username and access key of your BrowserStack account. These can be found on the automate accounts page on [BrowserStack](https://www.browserstack.com/accounts/automate) `export BROWSERSTACK_USERNAME=<browserstack-username> && export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>`
11-
3. Install the dependencies by running `npm install browserstack browserstack-local`
12-
4. Install testem globally by running `npm install testem -g`
13-
5. Run the command `testem ci -l bs_chrome` to test out the setup with just the Chrome browser hosted BrowserStack.
14-
6. Run `testem ci` to run it on all the listed browsers - see `testem launchers` for the full list.
11+
## Running yourtests
12+
* To run a single test, run `npm run single`
13+
* To run parallel tests, run `npm run parallel`
14+
15+
## Notes
16+
* You can view your test results on the [BrowserStack automate dashboard](https://www.browserstack.com/automate)
17+
* To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/node#setting-os-and-browser)
18+
* You can export the environment variables for the Username and Access Key of your BrowserStack account
19+
20+
```
21+
export BROWSERSTACK_USERNAME=<browserstack-username> &&
22+
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
23+
```
24+
25+
## Additional Resources
26+
* [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities)
27+
* [Browsers & mobile devices for JavaScript testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=js_testing)
28+
* [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api)
29+

bin/stop-BrowserStackLocal.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "testem-browserstack",
3+
"version": "0.1.0",
4+
"readme": "Testem Integration with [BrowserStack](https://www.browserstack.com)",
5+
"description": "Selenium examples for Testem and BrowserStack Automate",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/browserstack/testem-browserstack.git"
9+
},
10+
"scripts": {
11+
"test": "npm run single && npm run parallel",
12+
"single": "./node_modules/.bin/testem ci -l bs_chrome",
13+
"parallel": "./node_modules/.bin/testem ci"
14+
},
15+
"devDependencies": {
16+
"testem": "*",
17+
"browserstack": "*",
18+
"selenium-webdriver": "^2.53.2"
19+
},
20+
"dependencies": {
21+
"browserstack-local": "^1.0.0"
22+
}
23+
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#!/usr/bin/env node
22

3+
if(process.argv[2]){
4+
process.kill(process.argv[2], 'SIGINT');
5+
process.exit(0);
6+
}
7+
38
var browserstack = require('browserstack-local');
49
var fs = require('fs');
510

6-
var pidFile = 'browserStackLocal.pid';
11+
var pidFile = 'browserstack-local.pid';
712
var bs_local = new browserstack.Local();
813
var bs_local_args = {
914
'key': process.env.BROWSERSTACK_ACCESS_KEY,
@@ -17,7 +22,7 @@ process.on('SIGINT', function() {
1722
if (error) {
1823
console.log(error);
1924
} else {
20-
console.log('BrowserStackLocal disconnected');
25+
console.log('BrowserStackLocal Disconnected');
2126
process.exit();
2227
}
2328
});
@@ -30,6 +35,6 @@ bs_local.start(bs_local_args, function(error) {
3035
if (error) {
3136
console.log(error);
3237
} else {
33-
console.log("Tunnel started");
38+
console.log("Tunnel Started");
3439
}
3540
});
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
var WORKER_ID = 0;
44
var BrowserStack = require('browserstack');
5+
var config = require('../testem.json');
56
var name = null
67

78
var client = BrowserStack.createClient({
8-
username: process.env.BROWSERSTACK_USERNAME,
9-
password: process.env.BROWSERSTACK_ACCESS_KEY
9+
username: process.env.BROWSERSTACK_USERNAME || config.bs_user,
10+
password: process.env.BROWSERSTACK_ACCESS_KEY || config.bs_key
1011
});
1112

1213
'SIGINT SIGTERM SIGHUP'.split(' ').forEach(function(evt) {
@@ -31,10 +32,9 @@ var settings = {
3132
browser_version: process.argv[5],
3233
device: process.argv[6],
3334
url: process.argv[7],
34-
3535
'browserstack.local': true,
3636
name: name,
37-
build: 'Testem Sample Tests'
37+
build: 'testem-browserstack'
3838
};
3939

4040
for (var i in settings) {
@@ -43,6 +43,8 @@ for (var i in settings) {
4343
}
4444
}
4545

46+
console.log(settings);
47+
4648
client.createWorker(settings, function(error, worker) {
4749
if (error) console.log(error);
4850
WORKER_ID = worker.id
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function hello(name){
22
return "hello " + (name || 'world');
3-
}
3+
}

test/hello_spec.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

testem.json

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,52 @@
11
{
2+
"bs_user": "BROWSERSTACK_USERNAME",
3+
"bs_key": "BROWSERSTACK_ACCESS_KEY",
4+
25
"framework": "jasmine",
3-
"parallel": 5,
6+
"parallel": 4,
7+
48
"on_start": {
5-
"command": "kill -9 $(ps -A | grep BrowserStackLocal | grep -v grep | cut -d ' ' -f2); ./bin/start-BrowserStackLocal.js &",
6-
"wait_for_text": "Tunnel started",
9+
"command": "kill -9 $(ps -A | grep BrowserStackLocal | grep -v grep | cut -d ' ' -f2); ./scripts/browserstack-local.js &",
10+
"wait_for_text": "Tunnel Started",
711
"wait_for_text_timeout": 300000
812
},
9-
"on_exit": "./bin/stop-BrowserStackLocal.js `cat browserStackLocal.pid`; rm browserStackLocal.pid",
13+
14+
"on_exit": "./scripts/browserstack-local.js `cat browserstack-local.pid`; rm browserstack-local.pid",
15+
1016
"launchers": {
11-
"bs_opera": {
12-
"exe": "./bin/run_on_browserstack.js",
13-
"args": [ "Windows", "10", "opera", "latest", "" ],
14-
"protocol": "browser"
15-
},
16-
17-
"bs_firefox": {
18-
"exe": "./bin/run_on_browserstack.js",
19-
"args": [ "Windows", "10", "firefox", "latest", "" ],
20-
"protocol": "browser"
21-
},
22-
2317
"bs_chrome": {
24-
"exe": "./bin/run_on_browserstack.js",
25-
"args": [ "OS X", "El Capitan", "chrome", "latest", "" ],
18+
"exe": "./scripts/browserstack.js",
19+
"args": [ "OSX", "ElCapitan", "chrome", "51.0", "" ],
2620
"protocol": "browser"
2721
},
28-
29-
"bs_safari_71": {
30-
"exe": "./bin/run_on_browserstack.js",
31-
"args": [ "OS X", "Mavericks", "safari", "7.1", "" ],
22+
"bs_firefox": {
23+
"exe": "./scripts/browserstack.js",
24+
"args": [ "Windows", "10", "firefox", "45.0", "" ],
3225
"protocol": "browser"
3326
},
34-
35-
"bs_safari_51": {
36-
"exe": "./bin/run_on_browserstack.js",
37-
"args": [ "OS X", "Snow Leopard", "safari", "5.1", "" ],
27+
"bs_safari": {
28+
"exe": "./scripts/browserstack.js",
29+
"args": [ "OSX", "ElCapitan", "safari", "9.1", "" ],
3830
"protocol": "browser"
3931
},
40-
41-
"bs_ie_11": {
42-
"exe": "./bin/run_on_browserstack.js",
32+
"bs_ie": {
33+
"exe": "./scripts/browserstack.js",
4334
"args": [ "Windows", "10", "ie", "11.0", "" ],
4435
"protocol": "browser"
4536
}
4637
},
38+
4739
"launch_in_dev": [],
40+
4841
"launch_in_ci": [
49-
"bs_opera",
5042
"bs_chrome",
5143
"bs_firefox",
52-
"bs_safari_71",
53-
"bs_safari_51",
54-
"bs_ie_11"
44+
"bs_safari",
45+
"bs_ie"
5546
],
47+
5648
"src_files": [
57-
"test/*"
49+
"src/*",
50+
"tests/*"
5851
]
5952
}

0 commit comments

Comments
 (0)