Skip to content

Commit bd2d84d

Browse files
joaaltoAndreyBelym
authored andcommitted
Allow specifying project name and build name. (#19)
1 parent fcc5ff9 commit bd2d84d

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: node_js
22
node_js:
33
- stable
4-
- '0.10'
4+
- '4'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ npm install testcafe-browser-provider-browserstack
1212
## Usage
1313
Before using this plugin, save the BrowserStack username and access key to environment variables `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY`.
1414

15+
Project name and build name will be displayed in BrowserStack if you set the environment variables `BROWSERSTACK_PROJECT_NAME` and `BROWSERSTACK_BUILD_ID`.
16+
1517
You can determine the available browser aliases by running
1618
```
1719
testcafe -b browserstack

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "1.1.1",
44
"description": "browserstack TestCafe browser provider plugin.",
55
"repository": "https://github.com/DevExpress/testcafe-browser-provider-browserstack",
6+
"engines": {
7+
"node": ">=4.0.0"
8+
},
69
"homepage": "https://github.com/DevExpress/testcafe-browser-provider-browserstack",
710
"author": {
811
"name": "Andrey Belym",

src/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { stringify as makeQueryString } from 'querystring';
21
import Promise from 'pinkie';
32
import request from 'request-promise';
43
import parseCapabilities from 'desired-capabilities';
@@ -7,6 +6,9 @@ import jimp from 'jimp';
76
import OS from 'os-family';
87
import nodeUrl from 'url';
98

9+
const BUILD_ID = process.env['BROWSERSTACK_BUILD_ID'];
10+
const PROJECT_NAME = process.env['BROWSERSTACK_PROJECT_NAME'];
11+
1012
const TESTS_TIMEOUT = process.env['BROWSERSTACK_TEST_TIMEOUT'] || 1800;
1113
const BROWSERSTACK_CONNECTOR_DELAY = 10000;
1214

@@ -122,15 +124,18 @@ function doRequest (apiPath, params) {
122124

123125
var url = apiPath.url;
124126

125-
if (params)
126-
url += '?' + makeQueryString(params);
127-
128127
var opts = {
129128
auth: {
130129
user: process.env['BROWSERSTACK_USERNAME'],
131130
pass: process.env['BROWSERSTACK_ACCESS_KEY'],
132131
},
133132

133+
qs: Object.assign({},
134+
BUILD_ID && { build: BUILD_ID },
135+
PROJECT_NAME && { project: PROJECT_NAME },
136+
params
137+
),
138+
134139
method: apiPath.method || 'GET',
135140
json: !apiPath.binaryStream
136141
};

test/mocha/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describe('Browser names', function () {
2929
'ie@11.0:Windows 8.1',
3030
'edge@14.0:Windows 10',
3131
'iPhone 6@8.3',
32-
'iPhone SE@10.0',
33-
'iPad Pro (9.7 inch)@10.0',
32+
'iPhone SE@10.3',
33+
'iPad Pro (9.7 inch)@10.3',
3434
'Google Nexus 5@5.0'
3535
]);
3636
});

0 commit comments

Comments
 (0)