jasmine-browser-runner 2.4.0 → 3.0.0-beta.1
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 +72 -33
- package/index.js +18 -17
- package/lib/command.js +1 -1
- package/lib/config.js +10 -11
- package/lib/examples/default_config.mjs +30 -0
- package/lib/examples/default_esm_config.mjs +34 -0
- package/lib/server.js +19 -27
- package/lib/types.js +12 -94
- package/lib/webdriver.js +1 -25
- package/package.json +4 -5
- package/lib/examples/default_config.json +0 -21
- package/lib/examples/default_esm_config.json +0 -21
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
jasmine-browser-runner runs your Jasmine specs in a browser. It's suitable for
|
|
2
2
|
interactive use with normal browsers as well as running specs in CI builds
|
|
3
|
-
using either headless
|
|
3
|
+
using either headless browsers or with a remote Selenuium grid provider
|
|
4
|
+
such as Saucelabs.
|
|
4
5
|
|
|
5
6
|
# Getting started
|
|
6
7
|
|
|
@@ -19,13 +20,21 @@ npx jasmine-browser-runner init
|
|
|
19
20
|
If you intend to use ES modules, add `--esm` to the `jasmine-browser-runner init`
|
|
20
21
|
command.
|
|
21
22
|
|
|
22
|
-
Then, customize `spec/support/jasmine-browser.
|
|
23
|
+
Then, customize `spec/support/jasmine-browser.mjs` to suit your needs. You can
|
|
23
24
|
change the spec files, helpers, and source files that are loaded, specify the
|
|
24
25
|
[Jasmine env's configuration](https://jasmine.github.io/api/edge/Configuration.html),
|
|
25
26
|
and more.
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
In addition to `spec/support/jasmine-browser.mjs`, jasmine-browser-runner also
|
|
29
|
+
supports other config file paths:
|
|
30
|
+
|
|
31
|
+
* `spec/support/jasmine-browser.js`
|
|
32
|
+
* `spec/support/jasmine-browser.json` (generated by previous versions of the
|
|
33
|
+
`init` subcommand)
|
|
34
|
+
* Any other JavaScript or JSON file, if you use the `--config` option. This
|
|
35
|
+
file can be a JSON file or a javascript file whose default export is a config
|
|
36
|
+
object.
|
|
37
|
+
|
|
29
38
|
More information about the configuration can be found at the runner [documentation website](https://jasmine.github.io/api/browser-runner/edge/Configuration.html).
|
|
30
39
|
|
|
31
40
|
To start the server so that you can run the specs interactively (particularly
|
|
@@ -42,10 +51,10 @@ npx jasmine-browser-runner runSpecs
|
|
|
42
51
|
```
|
|
43
52
|
|
|
44
53
|
To use a browser other than Firefox, add a `browser` field to
|
|
45
|
-
`jasmine-browser.
|
|
54
|
+
`jasmine-browser.mjs`:
|
|
46
55
|
|
|
47
56
|
```javascript
|
|
48
|
-
{
|
|
57
|
+
export default {
|
|
49
58
|
// ...
|
|
50
59
|
"browser": "chrome"
|
|
51
60
|
}
|
|
@@ -57,10 +66,10 @@ Its value can be `"firefox"`, `"headlessFirefox"`, `"safari"`,
|
|
|
57
66
|
## TLS support
|
|
58
67
|
|
|
59
68
|
To serve tests over HTTPS instead of HTTP, supply a path to a TLS cert and key
|
|
60
|
-
in PEM format in `jasmine-browser.
|
|
69
|
+
in PEM format in `jasmine-browser.mjs`:
|
|
61
70
|
|
|
62
71
|
```javascript
|
|
63
|
-
{
|
|
72
|
+
export default {
|
|
64
73
|
// ...
|
|
65
74
|
"tlsKey": "/path/to/tlsKey.pem",
|
|
66
75
|
"tlsCert": "/path/to/tlsCert.pem",
|
|
@@ -74,13 +83,27 @@ Note that if you are using a self-signed or otherwise invalid certificate, the
|
|
|
74
83
|
browser will not allow the connection by default. Additional browser configs
|
|
75
84
|
or command line options may be necessary to use an invalid TLS certificate.
|
|
76
85
|
|
|
86
|
+
## Controlling which network interfaces are listened to
|
|
87
|
+
|
|
88
|
+
By default, jasmine-browser-runner listens to all available network interfaces.
|
|
89
|
+
You might need that if you're using a remote grid such as Saucelabs. If you
|
|
90
|
+
don't need that, you can improve security by listening only to localhost.
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
export default {
|
|
94
|
+
// ...
|
|
95
|
+
"listenAddress": "localhost",
|
|
96
|
+
// ...
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
77
100
|
## Hostname support
|
|
78
101
|
|
|
79
|
-
|
|
80
|
-
`
|
|
102
|
+
If you need to access your tests via a specific hostname, you can do that by
|
|
103
|
+
setting the `hostname` configuration property:
|
|
81
104
|
|
|
82
105
|
```javascript
|
|
83
|
-
{
|
|
106
|
+
export default {
|
|
84
107
|
// ...
|
|
85
108
|
"hostname": "mymachine.mynetwork",
|
|
86
109
|
// ...
|
|
@@ -89,6 +112,11 @@ To serve tests on a specific interface or IP, you can specify a hostname in
|
|
|
89
112
|
|
|
90
113
|
This can also be specified on the command line with `--hostname`.
|
|
91
114
|
|
|
115
|
+
Setting `hostname` but not `listenAddress` has the same effect as setting
|
|
116
|
+
`listenAddress` to the same value as `hostname`. If you need to set a hostname
|
|
117
|
+
but retain the default behavior of listening to all network interfaces, you can
|
|
118
|
+
do that by setting `listenAddress` to `"*"`.
|
|
119
|
+
|
|
92
120
|
There are a few important caveats when doing this:
|
|
93
121
|
|
|
94
122
|
1. This name must either be an IP or a name that can really be resolved on your
|
|
@@ -132,7 +160,7 @@ If you have specs or helper files that use top-level await, set the
|
|
|
132
160
|
are also supported:
|
|
133
161
|
|
|
134
162
|
```javascript
|
|
135
|
-
{
|
|
163
|
+
export default {
|
|
136
164
|
// ...
|
|
137
165
|
"importMap": {
|
|
138
166
|
"moduleRootDir": "node_modules",
|
|
@@ -154,9 +182,9 @@ whether you use the Asset Pipeline or Webpacker.
|
|
|
154
182
|
|
|
155
183
|
1. Run `yarn add --dev jasmine-browser-runner jasmine-core`.
|
|
156
184
|
2. Run `npx jasmine-browser-runner init`.
|
|
157
|
-
3. Edit `spec/support/jasmine-browser.
|
|
185
|
+
3. Edit `spec/support/jasmine-browser.mjs` as follows:
|
|
158
186
|
```
|
|
159
|
-
{
|
|
187
|
+
export default {
|
|
160
188
|
"srcDir": ".",
|
|
161
189
|
"srcFiles": [],
|
|
162
190
|
"specDir": "public/packs/js",
|
|
@@ -196,9 +224,9 @@ To run the specs:
|
|
|
196
224
|
the Rails application.
|
|
197
225
|
2. Run `yarn add --dev jasmine-browser-runner`.
|
|
198
226
|
3. Run `npx jasmine-browser-runner init`.
|
|
199
|
-
5. Edit `spec/support/jasmine-browser.
|
|
227
|
+
5. Edit `spec/support/jasmine-browser.mjs` as follows:
|
|
200
228
|
```
|
|
201
|
-
{
|
|
229
|
+
export default {
|
|
202
230
|
"srcDir": "public/assets",
|
|
203
231
|
"srcFiles": [
|
|
204
232
|
"application-*.js"
|
|
@@ -230,9 +258,9 @@ provider like [Saucelabs](https://saucelabs.com/),
|
|
|
230
258
|
To use a remote grid hub, set the `browser` object
|
|
231
259
|
in your config file as follows:
|
|
232
260
|
|
|
233
|
-
```
|
|
234
|
-
// jasmine-browser.
|
|
235
|
-
{
|
|
261
|
+
```javascript
|
|
262
|
+
// jasmine-browser.mjs
|
|
263
|
+
export default {
|
|
236
264
|
// ...
|
|
237
265
|
// BrowserStack
|
|
238
266
|
"browser": {
|
|
@@ -254,9 +282,9 @@ in your config file as follows:
|
|
|
254
282
|
}
|
|
255
283
|
}
|
|
256
284
|
```
|
|
257
|
-
```
|
|
258
|
-
// jasmine-browser.
|
|
259
|
-
{
|
|
285
|
+
```javascript
|
|
286
|
+
// jasmine-browser.mjs
|
|
287
|
+
export default {
|
|
260
288
|
// ...
|
|
261
289
|
// Saucelabs
|
|
262
290
|
"browser": {
|
|
@@ -292,13 +320,24 @@ second parameter to`startServer`.
|
|
|
292
320
|
## Want more control?
|
|
293
321
|
|
|
294
322
|
```javascript
|
|
295
|
-
|
|
296
|
-
|
|
323
|
+
// ESM
|
|
324
|
+
import path from 'path';
|
|
325
|
+
import jasmineBrowser from 'jasmine-browser-runner';
|
|
326
|
+
import config from './spec/support/jasmine-browser.mjs';
|
|
297
327
|
|
|
298
|
-
const config = require(path.resolve('spec/support/jasmine-browser.json'));
|
|
299
328
|
config.projectBaseDir = path.resolve('some/path');
|
|
300
|
-
|
|
301
329
|
jasmineBrowser.startServer(config, { port: 4321 });
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
// CommonJS
|
|
333
|
+
const path = require('path');
|
|
334
|
+
const jasmineBrowser = require('jasmine-browser-runner');
|
|
335
|
+
|
|
336
|
+
import('./spec/support/jasmine-browser.mjs')
|
|
337
|
+
.then(function({default: config}) {
|
|
338
|
+
config.projectBaseDir = path.resolve('some/path');
|
|
339
|
+
jasmineBrowser.startServer(config, { port: 4321 });
|
|
340
|
+
});
|
|
302
341
|
```
|
|
303
342
|
|
|
304
343
|
## Supported environments
|
|
@@ -306,13 +345,13 @@ jasmineBrowser.startServer(config, { port: 4321 });
|
|
|
306
345
|
jasmine-browser-runner tests itself across popular browsers (Safari, Chrome,
|
|
307
346
|
Firefox, and Microsoft Edge) as well as Node.
|
|
308
347
|
|
|
309
|
-
| Environment | Supported versions
|
|
310
|
-
|
|
311
|
-
| Node | 18, 20
|
|
312
|
-
| Safari | 15-17
|
|
313
|
-
| Chrome | Evergreen
|
|
314
|
-
| Firefox | Evergreen, 102, 115
|
|
315
|
-
| Edge | Evergreen
|
|
348
|
+
| Environment | Supported versions |
|
|
349
|
+
|-------------------|--------------------------|
|
|
350
|
+
| Node | 18, 20, 22 |
|
|
351
|
+
| Safari | 15-17 |
|
|
352
|
+
| Chrome | Evergreen |
|
|
353
|
+
| Firefox | Evergreen, 102, 115, 128 |
|
|
354
|
+
| Edge | Evergreen |
|
|
316
355
|
|
|
317
356
|
For evergreen browsers, each version of jasmine-browser-runner is tested against
|
|
318
357
|
the version of the browser that is available to us at the time of release. Other
|
package/index.js
CHANGED
|
@@ -56,13 +56,12 @@ module.exports = {
|
|
|
56
56
|
/**
|
|
57
57
|
* Starts a {@link Server} that will serve the specs and supporting files via HTTP.
|
|
58
58
|
* @param {ServerCtorOptions} options to use to construct the server
|
|
59
|
-
* @param {ServerStartOptions} serverOptions Options to use to start the server
|
|
60
59
|
* @return {Promise<undefined>} A promise that is resolved when the server is
|
|
61
60
|
* started.
|
|
62
61
|
*/
|
|
63
|
-
startServer: function(options
|
|
62
|
+
startServer: function(options) {
|
|
64
63
|
const server = new Server(options);
|
|
65
|
-
return server.start(
|
|
64
|
+
return server.start();
|
|
66
65
|
},
|
|
67
66
|
/**
|
|
68
67
|
* Runs the specs.
|
|
@@ -70,8 +69,18 @@ module.exports = {
|
|
|
70
69
|
* @return {Promise<JasmineDoneInfo>} A promise that resolves to the {@link https://jasmine.github.io/api/edge/global.html#JasmineDoneInfo|overall result} when the suite has finished running.
|
|
71
70
|
*/
|
|
72
71
|
runSpecs: async function(options, deps) {
|
|
73
|
-
options = options
|
|
72
|
+
options = { ...options };
|
|
74
73
|
deps = deps || {};
|
|
74
|
+
const useRemote = options.browser && options.browser.useRemoteSeleniumGrid;
|
|
75
|
+
|
|
76
|
+
if (!options.port) {
|
|
77
|
+
if (useRemote) {
|
|
78
|
+
options.port = 5555;
|
|
79
|
+
} else {
|
|
80
|
+
options.port = 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
75
84
|
const ServerClass = deps.Server || Server;
|
|
76
85
|
const RunnerClass = deps.Runner || Runner;
|
|
77
86
|
const buildWebdriver =
|
|
@@ -80,19 +89,11 @@ module.exports = {
|
|
|
80
89
|
const server = new ServerClass(options);
|
|
81
90
|
|
|
82
91
|
const reporters = await createReporters(options, deps);
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (options.port) {
|
|
88
|
-
portRequest = options.port;
|
|
89
|
-
} else if (useSauce || useRemote) {
|
|
90
|
-
portRequest = 5555;
|
|
91
|
-
} else {
|
|
92
|
-
portRequest = 0;
|
|
93
|
-
}
|
|
92
|
+
const useSauceCompletionReporting =
|
|
93
|
+
useRemote &&
|
|
94
|
+
options.browser.remoteSeleniumGrid?.url?.includes('saucelabs.com');
|
|
94
95
|
|
|
95
|
-
await server.start(
|
|
96
|
+
await server.start();
|
|
96
97
|
|
|
97
98
|
try {
|
|
98
99
|
const webdriver = buildWebdriver(options.browser);
|
|
@@ -122,7 +123,7 @@ module.exports = {
|
|
|
122
123
|
|
|
123
124
|
return details;
|
|
124
125
|
} finally {
|
|
125
|
-
if (
|
|
126
|
+
if (useSauceCompletionReporting) {
|
|
126
127
|
await webdriver.executeScript(
|
|
127
128
|
`sauce:job-result=${process.exitCode === 0}`
|
|
128
129
|
);
|
package/lib/command.js
CHANGED
package/lib/config.js
CHANGED
|
@@ -20,10 +20,12 @@ async function loadConfig(baseDir, cliOptions) {
|
|
|
20
20
|
|
|
21
21
|
const candidates = (specifiedConfigFile
|
|
22
22
|
? [specifiedConfigFile]
|
|
23
|
-
: [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
: [
|
|
24
|
+
'spec/support/jasmine-browser.mjs',
|
|
25
|
+
'spec/support/jasmine-browser.js',
|
|
26
|
+
'spec/support/jasmine-browser.json',
|
|
27
|
+
]
|
|
28
|
+
).map(name => path.resolve(baseDir, name));
|
|
27
29
|
|
|
28
30
|
const fullPath = candidates.find(p => fs.existsSync(p));
|
|
29
31
|
|
|
@@ -57,18 +59,15 @@ function validateConfig(config) {
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
function defaultConfig() {
|
|
60
|
-
return fs.readFileSync(require.resolve('./examples/default_config.
|
|
62
|
+
return fs.readFileSync(require.resolve('./examples/default_config.mjs'), {
|
|
61
63
|
encoding: 'utf8',
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
function defaultEsmConfig() {
|
|
66
|
-
return fs.readFileSync(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
encoding: 'utf8',
|
|
70
|
-
}
|
|
71
|
-
);
|
|
68
|
+
return fs.readFileSync(require.resolve('./examples/default_esm_config.mjs'), {
|
|
69
|
+
encoding: 'utf8',
|
|
70
|
+
});
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
function validateImportMap(importMap) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
srcDir: "src",
|
|
3
|
+
srcFiles: [
|
|
4
|
+
"**/*.js"
|
|
5
|
+
],
|
|
6
|
+
specDir: "spec",
|
|
7
|
+
specFiles: [
|
|
8
|
+
"**/*[sS]pec.js"
|
|
9
|
+
],
|
|
10
|
+
helpers: [
|
|
11
|
+
"helpers/**/*.js"
|
|
12
|
+
],
|
|
13
|
+
env: {
|
|
14
|
+
stopSpecOnExpectationFailure: false,
|
|
15
|
+
stopOnSpecFailure: false,
|
|
16
|
+
random: true
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// For security, listen only to localhost. You can also specify a different
|
|
20
|
+
// hostname or IP address, or remove the property or set it to "*" to listen
|
|
21
|
+
// to all network interfaces.
|
|
22
|
+
listenAddress: "localhost",
|
|
23
|
+
|
|
24
|
+
// The hostname that the browser will use to connect to the server.
|
|
25
|
+
hostname: "localhost",
|
|
26
|
+
|
|
27
|
+
browser: {
|
|
28
|
+
name: "firefox"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
srcDir: "src",
|
|
3
|
+
// srcFiles should usually be left empty when using ES modules, because you'll
|
|
4
|
+
// explicitly import sources from your specs.
|
|
5
|
+
srcFiles: [],
|
|
6
|
+
specDir: ".",
|
|
7
|
+
specFiles: [
|
|
8
|
+
"spec/**/*[sS]pec.?(m)js"
|
|
9
|
+
],
|
|
10
|
+
helpers: [
|
|
11
|
+
"spec/helpers/**/*.?(m)js"
|
|
12
|
+
],
|
|
13
|
+
esmFilenameExtension: ".mjs",
|
|
14
|
+
// Allows the use of top-level await in src/spec/helper files. This is off by
|
|
15
|
+
// default because it makes files load more slowly.
|
|
16
|
+
enableTopLevelAwait: false,
|
|
17
|
+
env: {
|
|
18
|
+
stopSpecOnExpectationFailure: false,
|
|
19
|
+
stopOnSpecFailure: false,
|
|
20
|
+
random: true
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// For security, listen only to localhost. You can also specify a different
|
|
24
|
+
// hostname or IP address, or remove the property or set it to "*" to listen
|
|
25
|
+
// to all network interfaces.
|
|
26
|
+
listenAddress: "localhost",
|
|
27
|
+
|
|
28
|
+
// The hostname that the browser will use to connect to the server.
|
|
29
|
+
hostname: "localhost",
|
|
30
|
+
|
|
31
|
+
browser: {
|
|
32
|
+
name: "firefox"
|
|
33
|
+
}
|
|
34
|
+
};
|
package/lib/server.js
CHANGED
|
@@ -15,8 +15,9 @@ class Server {
|
|
|
15
15
|
* @constructor
|
|
16
16
|
* @param {ServerCtorOptions} options
|
|
17
17
|
*/
|
|
18
|
-
constructor(options) {
|
|
18
|
+
constructor(options, deps) {
|
|
19
19
|
this.options = { ...options };
|
|
20
|
+
this._deps = deps || { http, https };
|
|
20
21
|
this.express = this.options.express || defaultExpress;
|
|
21
22
|
this.useHtmlReporter =
|
|
22
23
|
options.useHtmlReporter === undefined ? true : options.useHtmlReporter;
|
|
@@ -132,11 +133,9 @@ class Server {
|
|
|
132
133
|
|
|
133
134
|
/**
|
|
134
135
|
* Starts the server.
|
|
135
|
-
* @param {ServerStartOptions} options
|
|
136
136
|
* @return {Promise<undefined>} A promise that resolves upon successful start.
|
|
137
137
|
*/
|
|
138
|
-
start(
|
|
139
|
-
serverOptions = serverOptions || {};
|
|
138
|
+
start() {
|
|
140
139
|
const app = this.express();
|
|
141
140
|
|
|
142
141
|
app.use('/__jasmine__', this.express.static(this.jasmineCore.files.path));
|
|
@@ -219,18 +218,23 @@ class Server {
|
|
|
219
218
|
}
|
|
220
219
|
});
|
|
221
220
|
|
|
222
|
-
const port =
|
|
223
|
-
const tlsCert =
|
|
224
|
-
const tlsKey =
|
|
225
|
-
const hostname =
|
|
221
|
+
const port = this.options.port === undefined ? 8888 : this.options.port;
|
|
222
|
+
const tlsCert = this.options.tlsCert;
|
|
223
|
+
const tlsKey = this.options.tlsKey;
|
|
224
|
+
const hostname = this.options.hostname;
|
|
225
|
+
let listenAddress;
|
|
226
|
+
|
|
227
|
+
if (!this.options.listenAddress) {
|
|
228
|
+
listenAddress = 'localhost';
|
|
229
|
+
} else if (this.options.listenAddress === '*') {
|
|
230
|
+
listenAddress = ''; // all interfaces
|
|
231
|
+
} else {
|
|
232
|
+
listenAddress = this.options.listenAddress;
|
|
233
|
+
}
|
|
226
234
|
|
|
227
|
-
// NOTE: Before hostname support, jasmine-browser-runner would listen on
|
|
228
|
-
// all IPs (no hostname) and point browsers to "localhost". We preserve
|
|
229
|
-
// backward compatibility here by using different defaults for these two
|
|
230
|
-
// things.
|
|
231
235
|
const listenOptions = {
|
|
232
236
|
port,
|
|
233
|
-
host:
|
|
237
|
+
host: listenAddress,
|
|
234
238
|
};
|
|
235
239
|
this._httpHostname = hostname || 'localhost';
|
|
236
240
|
|
|
@@ -260,12 +264,12 @@ class Server {
|
|
|
260
264
|
key: fs.readFileSync(tlsKey),
|
|
261
265
|
cert: fs.readFileSync(tlsCert),
|
|
262
266
|
};
|
|
263
|
-
this._httpServer = https
|
|
267
|
+
this._httpServer = this._deps.https
|
|
264
268
|
.createServer(httpsOptions, app)
|
|
265
269
|
.listen(listenOptions, callback);
|
|
266
270
|
this._httpServerScheme = 'https';
|
|
267
271
|
} else {
|
|
268
|
-
this._httpServer = http
|
|
272
|
+
this._httpServer = this._deps.http
|
|
269
273
|
.createServer(app)
|
|
270
274
|
.listen(listenOptions, callback);
|
|
271
275
|
this._httpServerScheme = 'http';
|
|
@@ -325,18 +329,6 @@ class Server {
|
|
|
325
329
|
}
|
|
326
330
|
}
|
|
327
331
|
|
|
328
|
-
function findPort(serverPort, optionsPort) {
|
|
329
|
-
if (typeof serverPort !== 'undefined') {
|
|
330
|
-
return serverPort;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (typeof optionsPort !== 'undefined') {
|
|
334
|
-
return optionsPort;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return 8888;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
332
|
function isUrl(s) {
|
|
341
333
|
return s.startsWith('http://') || s.startsWith('https://');
|
|
342
334
|
}
|
package/lib/types.js
CHANGED
|
@@ -52,12 +52,19 @@
|
|
|
52
52
|
* @type string
|
|
53
53
|
*/
|
|
54
54
|
/**
|
|
55
|
-
* The hostname
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
55
|
+
* The hostname or IP address of the network interface to listen on. For
|
|
56
|
+
* security, jasmine-browser-runner will listen to localhost unless if this
|
|
57
|
+
* property is not specified. Set to "*" to listen on all interfaces, which may
|
|
58
|
+
* be required by some remote Selenium grids.
|
|
59
|
+
* @name ServerCtorOptions#listenAddress
|
|
60
|
+
* @default "localhost"
|
|
61
|
+
* @type string | undefined
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* The hostname to use in the URL given to browsers.
|
|
59
65
|
* @name ServerCtorOptions#hostname
|
|
60
|
-
* @
|
|
66
|
+
* @default "localhost"
|
|
67
|
+
* @type string | undefined
|
|
61
68
|
*/
|
|
62
69
|
/**
|
|
63
70
|
* The root directory of the project.
|
|
@@ -180,12 +187,6 @@
|
|
|
180
187
|
* Describes a web browser.
|
|
181
188
|
* @interface BrowserInfo
|
|
182
189
|
*/
|
|
183
|
-
/**
|
|
184
|
-
* Whether to run the specs on {@link https://saucelabs.com/|Saucelabs}.
|
|
185
|
-
* Defaults to false.
|
|
186
|
-
* @name BrowserInfo#useSauce
|
|
187
|
-
* @type boolean | undefined
|
|
188
|
-
*/
|
|
189
190
|
/**
|
|
190
191
|
* Whether to run the specs on a remote Selenium grid.
|
|
191
192
|
* Defaults to false.
|
|
@@ -198,63 +199,11 @@
|
|
|
198
199
|
* @name BrowserInfo#name
|
|
199
200
|
* @type string | undefined
|
|
200
201
|
*/
|
|
201
|
-
/**
|
|
202
|
-
* Configuration for running specs on {@link https://saucelabs.com/|Saucelabs}
|
|
203
|
-
* @name BrowserInfo#sauce
|
|
204
|
-
* @type SauceConfig | undefined
|
|
205
|
-
*/
|
|
206
202
|
/**
|
|
207
203
|
* Configuration for running specs on a remote Selenium grid
|
|
208
204
|
* @name BrowserInfo#remoteSeleniumGrid
|
|
209
205
|
* @type RemoteSeleniumGridConfig | undefined
|
|
210
206
|
*/
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Configuration for running specs on {@link https://saucelabs.com/|Saucelabs}
|
|
214
|
-
* @interface SauceConfig
|
|
215
|
-
*/
|
|
216
|
-
/**
|
|
217
|
-
* Saucelabs username
|
|
218
|
-
* @name SauceConfig#username
|
|
219
|
-
* @type string
|
|
220
|
-
*/
|
|
221
|
-
/**
|
|
222
|
-
* Saucelabs access key
|
|
223
|
-
* @name SauceConfig#accessKey
|
|
224
|
-
* @type string
|
|
225
|
-
*/
|
|
226
|
-
/**
|
|
227
|
-
* Browser version. Omit this to use the latest version of the specified browser.
|
|
228
|
-
* @name SauceConfig#browserVersion
|
|
229
|
-
* @type string
|
|
230
|
-
*/
|
|
231
|
-
/**
|
|
232
|
-
* Identifier of the Sauce Connect tunnel to use.
|
|
233
|
-
* @name SauceConfig#tunnelIdentifier
|
|
234
|
-
* @type string
|
|
235
|
-
*/
|
|
236
|
-
/**
|
|
237
|
-
* Operating system to run the browser on.
|
|
238
|
-
*
|
|
239
|
-
* _Note_: It's best to omit this property
|
|
240
|
-
* unless you really need your specs to run on a specific OS. If you omit it,
|
|
241
|
-
* Saucelabs will select a suitable OS. If you specify an unsupported combination
|
|
242
|
-
* of os and browserVersion, Saucelabs will select a different browser version
|
|
243
|
-
* that's available on the specified OS.
|
|
244
|
-
* @name SauceConfig#os
|
|
245
|
-
* @type string
|
|
246
|
-
*/
|
|
247
|
-
/**
|
|
248
|
-
* Build identifier to pass to Saucelabs
|
|
249
|
-
* @name SauceConfig#build
|
|
250
|
-
* @type string
|
|
251
|
-
*/
|
|
252
|
-
/**
|
|
253
|
-
* Tags to pass to Saucelabs
|
|
254
|
-
* @name SauceConfig#tags
|
|
255
|
-
* @type Array.<string>
|
|
256
|
-
*/
|
|
257
|
-
|
|
258
207
|
/**
|
|
259
208
|
* Configuration for running specs on a remote Selenium grid
|
|
260
209
|
* Any additional properties, such as "sauce:options" or "bstack:options", will
|
|
@@ -281,37 +230,6 @@
|
|
|
281
230
|
* @type string
|
|
282
231
|
*/
|
|
283
232
|
|
|
284
|
-
/**
|
|
285
|
-
* Options passed to {@link Server#start}
|
|
286
|
-
* @interface
|
|
287
|
-
* @name ServerStartOptions
|
|
288
|
-
*/
|
|
289
|
-
/**
|
|
290
|
-
* The port number to listen on.
|
|
291
|
-
* @name ServerStartOptions#port
|
|
292
|
-
* @type number | undefined
|
|
293
|
-
*/
|
|
294
|
-
/**
|
|
295
|
-
* The path to a TLS key. Activates HTTPS mode. If specified, tlsCert must also
|
|
296
|
-
* be specified.
|
|
297
|
-
* @name ServerStartOptions#tlsKey
|
|
298
|
-
* @type string
|
|
299
|
-
*/
|
|
300
|
-
/**
|
|
301
|
-
* The path to a TLS cert. Activates HTTPS mode. If specified, tlsKey must also
|
|
302
|
-
* be specified.
|
|
303
|
-
* @name ServerStartOptions#tlsCert
|
|
304
|
-
* @type string
|
|
305
|
-
*/
|
|
306
|
-
/**
|
|
307
|
-
* The hostname to use. This influences both the URL given to browsers and the
|
|
308
|
-
* addresses on which the socket listens. If blank, for backward
|
|
309
|
-
* compatibility, the browsers will be pointed to localhost, but the listening
|
|
310
|
-
* socket will listen on all IPs.
|
|
311
|
-
* @name ServerStartOptions#hostname
|
|
312
|
-
* @type string
|
|
313
|
-
*/
|
|
314
|
-
|
|
315
233
|
/**
|
|
316
234
|
* Describes an import map.
|
|
317
235
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap}
|
package/lib/webdriver.js
CHANGED
|
@@ -3,7 +3,6 @@ function buildWebdriver(browserInfo, webdriverBuilder) {
|
|
|
3
3
|
Capability = webdriver.Capability;
|
|
4
4
|
|
|
5
5
|
webdriverBuilder = webdriverBuilder || new webdriver.Builder();
|
|
6
|
-
const useSauce = typeof browserInfo === 'object' && browserInfo.useSauce;
|
|
7
6
|
const useRemote =
|
|
8
7
|
typeof browserInfo === 'object' && browserInfo.useRemoteSeleniumGrid;
|
|
9
8
|
let browserName;
|
|
@@ -16,7 +15,7 @@ function buildWebdriver(browserInfo, webdriverBuilder) {
|
|
|
16
15
|
|
|
17
16
|
browserName = browserName || 'firefox';
|
|
18
17
|
|
|
19
|
-
if (!
|
|
18
|
+
if (!useRemote) {
|
|
20
19
|
if (browserName === 'headlessChrome') {
|
|
21
20
|
const caps = webdriver.Capabilities.chrome();
|
|
22
21
|
caps.set('goog:chromeOptions', {
|
|
@@ -58,29 +57,6 @@ function buildWebdriver(browserInfo, webdriverBuilder) {
|
|
|
58
57
|
};
|
|
59
58
|
delete capabilities.url;
|
|
60
59
|
}
|
|
61
|
-
} else if (useSauce) {
|
|
62
|
-
// handle legacy `sauce` object
|
|
63
|
-
console.warn(
|
|
64
|
-
'Deprecation warning: Direct support for Saucelabs is deprecated and ' +
|
|
65
|
-
'will be removed in a future release. Please use Saucelabs via the ' +
|
|
66
|
-
'remote Selenium grid feature. See the jasmine-browser-runner README ' +
|
|
67
|
-
'for details.'
|
|
68
|
-
);
|
|
69
|
-
const sauce = browserInfo.sauce;
|
|
70
|
-
if (sauce) {
|
|
71
|
-
url = `http://${sauce.username}:${sauce.accessKey}@ondemand.saucelabs.com/wd/hub`;
|
|
72
|
-
capabilities = {
|
|
73
|
-
[Capability.BROWSER_NAME]: browserName,
|
|
74
|
-
build: sauce.build,
|
|
75
|
-
tags: sauce.tags,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
capabilities[Capability.PLATFORM_NAME] = sauce.os;
|
|
79
|
-
capabilities[Capability.BROWSER_VERSION] = sauce.browserVersion;
|
|
80
|
-
capabilities['sauce:options'] = {
|
|
81
|
-
'tunnel-identifier': sauce.tunnelIdentifier,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
60
|
}
|
|
85
61
|
|
|
86
62
|
if (!capabilities) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jasmine-browser-runner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"description": "Serve and run your Jasmine specs in a browser",
|
|
5
5
|
"bin": "bin/jasmine-browser-runner",
|
|
6
6
|
"exports": "./index.js",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"run.html.ejs",
|
|
14
14
|
"bin/*.js",
|
|
15
15
|
"lib/**/*.js",
|
|
16
|
-
"lib/examples/default_config.
|
|
17
|
-
"lib/examples/default_esm_config.
|
|
16
|
+
"lib/examples/default_config.mjs",
|
|
17
|
+
"lib/examples/default_esm_config.mjs"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"posttest": "eslint bin/* lib spec index.js --ignore-path=.styleIgnore && prettier --check --ignore-path=.styleIgnore \"lib/**/*.js\" \"spec/**/*.js\" index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"homepage": "https://github.com/jasmine/jasmine-browser-runner#readme",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"ejs": "^3.1.6",
|
|
41
|
-
"express": "^
|
|
41
|
+
"express": "^5.0.0",
|
|
42
42
|
"glob": "^10.0.0",
|
|
43
43
|
"selenium-webdriver": "^4.12.0"
|
|
44
44
|
},
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"jasmine-core": "^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"ejs-lint": "^2.0.0",
|
|
50
49
|
"eslint": "^8.50.0",
|
|
51
50
|
"eslint-plugin-jasmine": "^4.1.3",
|
|
52
51
|
"jasmine": "^5.0.0",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"srcDir": "src",
|
|
3
|
-
"srcFiles": [
|
|
4
|
-
"**/*.js"
|
|
5
|
-
],
|
|
6
|
-
"specDir": "spec",
|
|
7
|
-
"specFiles": [
|
|
8
|
-
"**/*[sS]pec.js"
|
|
9
|
-
],
|
|
10
|
-
"helpers": [
|
|
11
|
-
"helpers/**/*.js"
|
|
12
|
-
],
|
|
13
|
-
"env": {
|
|
14
|
-
"stopSpecOnExpectationFailure": false,
|
|
15
|
-
"stopOnSpecFailure": false,
|
|
16
|
-
"random": true
|
|
17
|
-
},
|
|
18
|
-
"browser": {
|
|
19
|
-
"name": "firefox"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"srcDir": "src",
|
|
3
|
-
"srcFiles": [],
|
|
4
|
-
"specDir": ".",
|
|
5
|
-
"specFiles": [
|
|
6
|
-
"spec/**/*[sS]pec.?(m)js"
|
|
7
|
-
],
|
|
8
|
-
"helpers": [
|
|
9
|
-
"spec/helpers/**/*.?(m)js"
|
|
10
|
-
],
|
|
11
|
-
"esmFilenameExtension": ".mjs",
|
|
12
|
-
"enableTopLevelAwait": false,
|
|
13
|
-
"env": {
|
|
14
|
-
"stopSpecOnExpectationFailure": false,
|
|
15
|
-
"stopOnSpecFailure": false,
|
|
16
|
-
"random": true
|
|
17
|
-
},
|
|
18
|
-
"browser": {
|
|
19
|
-
"name": "firefox"
|
|
20
|
-
}
|
|
21
|
-
}
|