jasmine-browser-runner 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -1
- package/index.js +5 -2
- package/lib/types.js +37 -0
- package/lib/webdriver.js +39 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -163,7 +163,71 @@ To run the specs:
|
|
|
163
163
|
2. Run `npx jasmine-browser-runner`.
|
|
164
164
|
3. Visit <http://localhost:8888>.
|
|
165
165
|
|
|
166
|
-
## Saucelabs
|
|
166
|
+
## Remote Grid support (Saucelabs, BrowserStack, etc.)
|
|
167
|
+
|
|
168
|
+
jasmine-browser-runner can run your Jasmine specs on a remote grid
|
|
169
|
+
provider like [Saucelabs](https://saucelabs.com/),
|
|
170
|
+
[BrowserStack](https://browserstack.com) or your own Selenium Grid.
|
|
171
|
+
To use a remote grid hub, set the `browser` object
|
|
172
|
+
in your config file as follows:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
// jasmine-browser.json
|
|
176
|
+
{
|
|
177
|
+
// ...
|
|
178
|
+
// BrowserStack
|
|
179
|
+
"browser": {
|
|
180
|
+
"name": "safari",
|
|
181
|
+
"useRemoteSeleniumGrid": true,
|
|
182
|
+
"remoteSeleniumGrid": {
|
|
183
|
+
"url": "https://hub-cloud.browserstack.com/wd/hub",
|
|
184
|
+
"bstack:options": {
|
|
185
|
+
"browserVersion": "16",
|
|
186
|
+
"os": "OS X",
|
|
187
|
+
"osVersion": "Monterey",
|
|
188
|
+
"local": "true",
|
|
189
|
+
"localIdentifier": "tunnel ID",
|
|
190
|
+
"debug": "true",
|
|
191
|
+
"userName": "your BrowserStack username",
|
|
192
|
+
"accessKey": "your BrowserStack access key"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
```json
|
|
199
|
+
// jasmine-browser.json
|
|
200
|
+
{
|
|
201
|
+
// ...
|
|
202
|
+
// Saucelabs
|
|
203
|
+
"browser": {
|
|
204
|
+
"name": "safari",
|
|
205
|
+
"useRemoteSeleniumGrid": true,
|
|
206
|
+
"remoteSeleniumGrid": {
|
|
207
|
+
"url": "https://ondemand.saucelabs.com/wd/hub",
|
|
208
|
+
"platformName": "macOS 12",
|
|
209
|
+
"sauce:options": {
|
|
210
|
+
"tunnel-identifier": "tunnel ID",
|
|
211
|
+
"userName": "your Saucelabs username",
|
|
212
|
+
"accessKey": "your Saucelabs access key"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
When using a remote grid provider, all properties of the `browser` object are
|
|
220
|
+
optional except for `name` which will be passed as the `browserName` capability,
|
|
221
|
+
and `useRemoteSeleniumGrid` which must be set to a value of `true`. if a
|
|
222
|
+
`remoteSeleniumGrid` object is included, any values it contains, with the
|
|
223
|
+
exception of the `url` will be used as `capabilties` sent to the grid hub url.
|
|
224
|
+
if no value is specified for the `url` then a default of
|
|
225
|
+
`http://localhost:4445/wd/hub` is used.
|
|
226
|
+
|
|
227
|
+
## Saucelabs support (legacy)
|
|
228
|
+
> NOTE: the below configuration format only supports using Saucelabs in the US. if connecting from the EU, please use the above specifying a `url` value specific to your region (e.g. `https://ondemand.eu-central-1.saucelabs.com:443/wd/hub`) to avoid a connection error of `WebDriverError: This user is unauthorized to the region. Please try another region, or contact customer support.`
|
|
229
|
+
|
|
230
|
+
> WARNING: the below configuration format may be removed in favour of using the above in the future so it is advised that you migrate to the above
|
|
167
231
|
|
|
168
232
|
jasmine-browser-runner can run your Jasmine specs on [Saucelabs](https://saucelabs.com/).
|
|
169
233
|
To use Saucelabs, set `browser.name`, `browser.useSauce`, and `browser.sauce`
|
package/index.js
CHANGED
|
@@ -81,11 +81,14 @@ module.exports = {
|
|
|
81
81
|
|
|
82
82
|
const reporters = await createReporters(options, deps);
|
|
83
83
|
const useSauce = options.browser && options.browser.useSauce;
|
|
84
|
+
const useRemote = options.browser && options.browser.useRemoteSeleniumGrid;
|
|
84
85
|
let portRequest;
|
|
85
86
|
|
|
86
|
-
if (useSauce) {
|
|
87
|
+
if (useSauce || useRemote) {
|
|
87
88
|
if (options.port) {
|
|
88
|
-
throw new Error(
|
|
89
|
+
throw new Error(
|
|
90
|
+
"Can't specify a port when browser.useSauce or browser.useRemoteSeleniumGrid is true"
|
|
91
|
+
);
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
portRequest = 5555;
|
package/lib/types.js
CHANGED
|
@@ -143,6 +143,12 @@
|
|
|
143
143
|
* @name BrowserInfo#useSauce
|
|
144
144
|
* @type boolean | undefined
|
|
145
145
|
*/
|
|
146
|
+
/**
|
|
147
|
+
* Whether to run the specs on a remote Selenium grid.
|
|
148
|
+
* Defaults to false.
|
|
149
|
+
* @name BrowserInfo#useRemoteSeleniumGrid
|
|
150
|
+
* @type boolean | undefined
|
|
151
|
+
*/
|
|
146
152
|
/**
|
|
147
153
|
* The browser name. Valid values include "firefox", "headlessFirefox",
|
|
148
154
|
* "safari", "MicrosoftEdge", "chrome", and "headlessChrome".
|
|
@@ -154,6 +160,11 @@
|
|
|
154
160
|
* @name BrowserInfo#sauce
|
|
155
161
|
* @type SauceConfig | undefined
|
|
156
162
|
*/
|
|
163
|
+
/**
|
|
164
|
+
* Configuration for running specs on a remote Selenium grid
|
|
165
|
+
* @name BrowserInfo#remoteSeleniumGrid
|
|
166
|
+
* @type RemoteSeleniumGridConfig | undefined
|
|
167
|
+
*/
|
|
157
168
|
|
|
158
169
|
/**
|
|
159
170
|
* Configuration for running specs on {@link https://saucelabs.com/|Saucelabs}
|
|
@@ -201,6 +212,32 @@
|
|
|
201
212
|
* @type Array.<string>
|
|
202
213
|
*/
|
|
203
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Configuration for running specs on a remote Selenium grid
|
|
217
|
+
* Any additional properties, such as "sauce:options" or "bstack:options", will
|
|
218
|
+
* be included in the capabilities object passed through to Selenium Webdriver.
|
|
219
|
+
* @interface RemoteSeleniumGridConfig
|
|
220
|
+
* @example
|
|
221
|
+
* {
|
|
222
|
+
* "url": "https://hub-cloud.browserstack.com/wd/hub",
|
|
223
|
+
* "bstack:options": {
|
|
224
|
+
* "browserVersion": "16",
|
|
225
|
+
* "os": "OS X",
|
|
226
|
+
* "osVersion": "Monterey",
|
|
227
|
+
* "local": "true",
|
|
228
|
+
* "localIdentifier": "tunnel ID",
|
|
229
|
+
* "debug": "true",
|
|
230
|
+
* "userName": "your BrowserStack username",
|
|
231
|
+
* "accessKey": "your BrowserStack access key"
|
|
232
|
+
* }
|
|
233
|
+
* }
|
|
234
|
+
*/
|
|
235
|
+
/**
|
|
236
|
+
* URL of the remote Selenium grid
|
|
237
|
+
* @name RemoteSeleniumGridConfig#url
|
|
238
|
+
* @type string
|
|
239
|
+
*/
|
|
240
|
+
|
|
204
241
|
/**
|
|
205
242
|
* Options passed to {@link Server#start}
|
|
206
243
|
* @interface
|
package/lib/webdriver.js
CHANGED
|
@@ -4,6 +4,8 @@ function buildWebdriver(browserInfo, webdriverBuilder) {
|
|
|
4
4
|
|
|
5
5
|
webdriverBuilder = webdriverBuilder || new webdriver.Builder();
|
|
6
6
|
const useSauce = typeof browserInfo === 'object' && browserInfo.useSauce;
|
|
7
|
+
const useRemote =
|
|
8
|
+
typeof browserInfo === 'object' && browserInfo.useRemoteSeleniumGrid;
|
|
7
9
|
let browserName;
|
|
8
10
|
|
|
9
11
|
if (typeof browserInfo === 'string') {
|
|
@@ -14,7 +16,7 @@ function buildWebdriver(browserInfo, webdriverBuilder) {
|
|
|
14
16
|
|
|
15
17
|
browserName = browserName || 'firefox';
|
|
16
18
|
|
|
17
|
-
if (!useSauce) {
|
|
19
|
+
if (!(useRemote || useSauce)) {
|
|
18
20
|
if (browserName === 'headlessChrome') {
|
|
19
21
|
const caps = webdriver.Capabilities.chrome();
|
|
20
22
|
caps.set('goog:chromeOptions', {
|
|
@@ -44,26 +46,46 @@ function buildWebdriver(browserInfo, webdriverBuilder) {
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
let url;
|
|
50
|
+
let capabilities;
|
|
51
|
+
if (useRemote) {
|
|
52
|
+
const remote = browserInfo.remoteSeleniumGrid;
|
|
53
|
+
if (remote) {
|
|
54
|
+
url = remote.url;
|
|
55
|
+
capabilities = {
|
|
56
|
+
...remote,
|
|
57
|
+
[Capability.BROWSER_NAME]: browserName,
|
|
58
|
+
};
|
|
59
|
+
delete capabilities.url;
|
|
60
|
+
}
|
|
61
|
+
} else if (useSauce) {
|
|
62
|
+
// handle legacy `sauce` object
|
|
63
|
+
const sauce = browserInfo.sauce;
|
|
64
|
+
if (sauce) {
|
|
65
|
+
url = `http://${sauce.username}:${sauce.accessKey}@ondemand.saucelabs.com/wd/hub`;
|
|
66
|
+
capabilities = {
|
|
67
|
+
[Capability.BROWSER_NAME]: browserName,
|
|
68
|
+
build: sauce.build,
|
|
69
|
+
tags: sauce.tags,
|
|
70
|
+
};
|
|
53
71
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
capabilities[Capability.PLATFORM_NAME] = sauce.os;
|
|
73
|
+
capabilities[Capability.BROWSER_VERSION] = sauce.browserVersion;
|
|
74
|
+
capabilities['sauce:options'] = {
|
|
75
|
+
'tunnel-identifier': sauce.tunnelIdentifier,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!capabilities) {
|
|
81
|
+
capabilities = {
|
|
82
|
+
[Capability.BROWSER_NAME]: browserName,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
59
85
|
|
|
60
86
|
return webdriverBuilder
|
|
61
87
|
.withCapabilities(capabilities)
|
|
62
|
-
.usingServer(
|
|
63
|
-
browserInfo.useSauce
|
|
64
|
-
? `http://${sauce.username}:${sauce.accessKey}@ondemand.saucelabs.com/wd/hub`
|
|
65
|
-
: 'http://@localhost:4445/wd/hub'
|
|
66
|
-
)
|
|
88
|
+
.usingServer(url || 'http://localhost:4445/wd/hub')
|
|
67
89
|
.build();
|
|
68
90
|
}
|
|
69
91
|
|