selenium-side-runner 3.16.0 → 4.0.0-alpha.15
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 +31 -12
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +160 -0
- package/dist/bin.js.map +1 -0
- package/dist/capabilities.d.ts +7 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +49 -66
- package/dist/capabilities.js.map +1 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +12 -18
- package/dist/config.js.map +1 -0
- package/dist/main.test.d.ts +2 -0
- package/dist/main.test.d.ts.map +1 -0
- package/dist/main.test.js +105 -0
- package/dist/main.test.js.map +1 -0
- package/dist/proxy.d.ts +3 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +67 -64
- package/dist/proxy.js.map +1 -0
- package/dist/register.d.ts +16 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +66 -0
- package/dist/register.js.map +1 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +169 -0
- package/dist/run.js.map +1 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/versioner.d.ts +2 -0
- package/dist/versioner.d.ts.map +1 -0
- package/dist/versioner.js +23 -22
- package/dist/versioner.js.map +1 -0
- package/jest.config.js +13 -0
- package/package.json +30 -25
- package/src/__tests__/capabilities.spec.ts +137 -0
- package/{dist/npm.js → src/__tests__/config.spec.ts} +8 -24
- package/src/__tests__/config_1.yml +4 -0
- package/src/__tests__/config_2.yml +3 -0
- package/src/__tests__/proxy.spec.ts +138 -0
- package/src/__tests__/versioner.spec.ts +44 -0
- package/src/bin.ts +202 -0
- package/src/capabilities.ts +87 -0
- package/{dist/util.js → src/config.ts} +11 -10
- package/src/main.test.ts +120 -0
- package/src/proxy.ts +89 -0
- package/src/register.ts +79 -0
- package/src/run.ts +182 -0
- package/src/types.ts +82 -0
- package/src/versioner.ts +36 -0
- package/tsconfig.json +19 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/.babelrc +0 -12
- package/dist/child.js +0 -7
- package/dist/index.js +0 -391
- package/dist/module-path.js +0 -41
package/package.json
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "selenium-side-runner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.15",
|
|
4
4
|
"description": "Run Selenium IDE projects in cli",
|
|
5
5
|
"repository": "https://github.com/SeleniumHQ/selenium-ide",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "babel -d dist src --ignore=src/__test__",
|
|
8
|
-
"prepublishOnly": "yarn build",
|
|
9
|
-
"watch": "yarn build -w"
|
|
10
|
-
},
|
|
11
6
|
"bin": {
|
|
12
|
-
"selenium-side-runner": "dist/
|
|
7
|
+
"selenium-side-runner": "dist/bin.js"
|
|
13
8
|
},
|
|
14
9
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
10
|
+
"node": ">=14"
|
|
16
11
|
},
|
|
17
12
|
"keywords": [
|
|
18
13
|
"selenium",
|
|
@@ -20,24 +15,34 @@
|
|
|
20
15
|
"line"
|
|
21
16
|
],
|
|
22
17
|
"license": "Apache-2.0",
|
|
23
|
-
"private": false,
|
|
24
18
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"jest
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"semver": "^
|
|
36
|
-
"winston": "^
|
|
19
|
+
"@seleniumhq/side-model": "^4.0.0-alpha.1",
|
|
20
|
+
"@seleniumhq/side-runtime": "^4.0.0-alpha.5",
|
|
21
|
+
"commander": "^9.4.0",
|
|
22
|
+
"glob": "^7.2.0",
|
|
23
|
+
"jest": "^27.5.1",
|
|
24
|
+
"jest-cli": "^27.5.1",
|
|
25
|
+
"jest-each": "^27.5.1",
|
|
26
|
+
"js-beautify": "^1.14.2",
|
|
27
|
+
"js-yaml": "^4.1.0",
|
|
28
|
+
"rimraf": "^3.0.2",
|
|
29
|
+
"semver": "^7.3.5",
|
|
30
|
+
"winston": "^3.6.0"
|
|
37
31
|
},
|
|
38
32
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
33
|
+
"@types/glob": "7.2.0",
|
|
34
|
+
"@types/jest": "^27.4.1",
|
|
35
|
+
"@types/js-beautify": "1.13.3",
|
|
36
|
+
"@types/js-yaml": "4.0.5",
|
|
37
|
+
"@types/rimraf": "3.0.2",
|
|
38
|
+
"@types/semver": "7.3.9",
|
|
39
|
+
"@types/winston": "2.4.4"
|
|
41
40
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
-
|
|
41
|
+
"gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744",
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc",
|
|
44
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo node_modules",
|
|
45
|
+
"start": "node dist/bin.js",
|
|
46
|
+
"watch": "tsc --watch"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
|
|
18
|
+
import Capabilities from '../capabilities'
|
|
19
|
+
|
|
20
|
+
describe('capabilities string parser', () => {
|
|
21
|
+
it('should parse capability key', () => {
|
|
22
|
+
const capabilities = 'browserName=chrome'
|
|
23
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
24
|
+
browserName: 'chrome',
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
it('should parse multiple capabilities keys', () => {
|
|
28
|
+
const capabilities =
|
|
29
|
+
'browserName=chrome platform=MAC unexpectedAlertBehaviour=ignore'
|
|
30
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
31
|
+
browserName: 'chrome',
|
|
32
|
+
platform: 'MAC',
|
|
33
|
+
unexpectedAlertBehaviour: 'ignore',
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
it('should parse quoted capability key', () => {
|
|
37
|
+
const capabilities = 'browserName="chrome"'
|
|
38
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
39
|
+
browserName: 'chrome',
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
it('should parse multiword capability key', () => {
|
|
43
|
+
const capabilities =
|
|
44
|
+
'binary="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
|
|
45
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
46
|
+
binary: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
47
|
+
})
|
|
48
|
+
const capabilities2 =
|
|
49
|
+
"binary='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'"
|
|
50
|
+
expect(Capabilities.parseString(capabilities2)).toEqual({
|
|
51
|
+
binary: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
it('should parse multiple multiword capability keys', () => {
|
|
55
|
+
const expected = {
|
|
56
|
+
browserName: 'internet explorer',
|
|
57
|
+
version: 10,
|
|
58
|
+
platform: 'Windows 8.1',
|
|
59
|
+
}
|
|
60
|
+
const capabilitiesSingleQuotes =
|
|
61
|
+
"browserName='internet explorer' version=10.0 platform='Windows 8.1'"
|
|
62
|
+
expect(Capabilities.parseString(capabilitiesSingleQuotes)).toEqual(expected)
|
|
63
|
+
const capabilitiesDoubleQuotes =
|
|
64
|
+
'browserName="internet explorer" version=10.0 platform="Windows 8.1"'
|
|
65
|
+
expect(Capabilities.parseString(capabilitiesDoubleQuotes)).toEqual(expected)
|
|
66
|
+
})
|
|
67
|
+
it('should parse boolean capability key', () => {
|
|
68
|
+
const capabilities = 'javascriptEnabled=false databaseEnabled=true'
|
|
69
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
70
|
+
javascriptEnabled: false,
|
|
71
|
+
databaseEnabled: true,
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
it('should parse integer capability key', () => {
|
|
75
|
+
const capabilities = 'elementScrollBehavior=1'
|
|
76
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
77
|
+
elementScrollBehavior: 1,
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
it('should parse dot-notation capability key', () => {
|
|
81
|
+
const capabilities = 'webdriver.remote.sessionid=someId'
|
|
82
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
83
|
+
webdriver: {
|
|
84
|
+
remote: {
|
|
85
|
+
sessionid: 'someId',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
it('should parse multiple dot-notation capability key', () => {
|
|
91
|
+
const capabilities = `
|
|
92
|
+
webdriver.remote.sessionid=someId
|
|
93
|
+
webdriver.remote.username=username
|
|
94
|
+
`
|
|
95
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
96
|
+
webdriver: {
|
|
97
|
+
remote: {
|
|
98
|
+
sessionid: 'someId',
|
|
99
|
+
username: 'username',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
it('should parse dot-notation arrays', () => {
|
|
105
|
+
const capabilities = 'chromeOptions.args=[disable-infobars, headless]'
|
|
106
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
107
|
+
chromeOptions: {
|
|
108
|
+
args: ['disable-infobars', 'headless'],
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
it('should parse space separated capability keys', () => {
|
|
113
|
+
const capabilities =
|
|
114
|
+
'browserName =chrome platform= MAC unexpectedAlertBehaviour = ignore'
|
|
115
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
116
|
+
browserName: 'chrome',
|
|
117
|
+
platform: 'MAC',
|
|
118
|
+
unexpectedAlertBehaviour: 'ignore',
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
it('should trim the capability values', () => {
|
|
122
|
+
const capabilities =
|
|
123
|
+
'platform=" macOS 10.13 " chromeOptions.args=[ disable-infobars , headless ]'
|
|
124
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
125
|
+
platform: 'macOS 10.13',
|
|
126
|
+
chromeOptions: {
|
|
127
|
+
args: ['disable-infobars', 'headless'],
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
it('should parse urls in list', () => {
|
|
132
|
+
const capabilities = 'bypass=[http://localhost:434, http://localhost:321]'
|
|
133
|
+
expect(Capabilities.parseString(capabilities)).toEqual({
|
|
134
|
+
bypass: ['http://localhost:434', 'http://localhost:321'],
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
})
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
1
|
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
2
|
// or more contributor license agreements. See the NOTICE file
|
|
5
3
|
// distributed with this work for additional information
|
|
@@ -16,27 +14,13 @@
|
|
|
16
14
|
// KIND, either express or implied. See the License for the
|
|
17
15
|
// specific language governing permissions and limitations
|
|
18
16
|
// under the License.
|
|
19
|
-
const npm = require('global-npm');
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
npm.load({
|
|
24
|
-
progress: false,
|
|
25
|
-
loglevel: 'silent'
|
|
26
|
-
}, e => {
|
|
27
|
-
if (e) {
|
|
28
|
-
rej(e);
|
|
29
|
-
} else {
|
|
30
|
-
npm.commands.install(e => {
|
|
31
|
-
if (e) {
|
|
32
|
-
rej(e);
|
|
33
|
-
} else {
|
|
34
|
-
res();
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
18
|
+
import path from 'path'
|
|
19
|
+
import Config from '../config'
|
|
41
20
|
|
|
42
|
-
|
|
21
|
+
describe('configuration loader', () => {
|
|
22
|
+
it('should load the config from a file', () => {
|
|
23
|
+
const configuration = Config.load(path.join(__dirname, 'config_1.yml'))
|
|
24
|
+
expect(configuration.capabilities).toBeDefined()
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
|
|
18
|
+
import ParseProxy from '../proxy'
|
|
19
|
+
|
|
20
|
+
describe('proxy parser', () => {
|
|
21
|
+
it('should parse a direct proxy', () => {
|
|
22
|
+
expect(ParseProxy('direct')).toEqual({
|
|
23
|
+
proxyType: 'direct',
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
it('should parse a system proxy', () => {
|
|
27
|
+
expect(ParseProxy('system')).toEqual({
|
|
28
|
+
proxyType: 'system',
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
it('should parse a pac proxy', () => {
|
|
32
|
+
expect(ParseProxy('pac', 'http://localhost/pac')).toEqual({
|
|
33
|
+
proxyType: 'pac',
|
|
34
|
+
proxyOptions: 'http://localhost/pac',
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
it('should throw if no pac file was given', () => {
|
|
38
|
+
expect(() => ParseProxy('pac')).toThrowError(
|
|
39
|
+
'A proxy autoconfig URL was not passed (e.g. --proxy-options="http://localhost/pac")'
|
|
40
|
+
)
|
|
41
|
+
})
|
|
42
|
+
it('should parse a manual proxy', () => {
|
|
43
|
+
expect(ParseProxy('manual', {})).toEqual({
|
|
44
|
+
proxyType: 'manual',
|
|
45
|
+
proxyOptions: {},
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
it('should omit redundant keys from the proxy', () => {
|
|
49
|
+
expect(
|
|
50
|
+
ParseProxy('manual', { test: 4, http: 'http://localhost:4324' })
|
|
51
|
+
).toEqual({
|
|
52
|
+
proxyType: 'manual',
|
|
53
|
+
proxyOptions: {
|
|
54
|
+
http: 'http://localhost:4324',
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
it('should whitelist the allowed proxy protocols', () => {
|
|
59
|
+
expect(
|
|
60
|
+
ParseProxy('manual', {
|
|
61
|
+
test: 4,
|
|
62
|
+
http: 'http://localhost:4324',
|
|
63
|
+
https: 'http://localhost:4324',
|
|
64
|
+
ftp: 'http://localhost:4324',
|
|
65
|
+
bypass: ['http://something.com'],
|
|
66
|
+
})
|
|
67
|
+
).toEqual({
|
|
68
|
+
proxyType: 'manual',
|
|
69
|
+
proxyOptions: {
|
|
70
|
+
http: 'http://localhost:4324',
|
|
71
|
+
https: 'http://localhost:4324',
|
|
72
|
+
ftp: 'http://localhost:4324',
|
|
73
|
+
bypass: ['http://something.com'],
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
it('should return an empty object if no options were given to manual proxy', () => {
|
|
78
|
+
expect(ParseProxy('manual')).toEqual({
|
|
79
|
+
proxyType: 'manual',
|
|
80
|
+
proxyOptions: {},
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
it('should throw if non object was passed to manual proxy type', () => {
|
|
84
|
+
// @ts-expect-error intentionally invalid type
|
|
85
|
+
expect(() => ParseProxy('manual', 5)).toThrowError(
|
|
86
|
+
'Proxy options were not passed to manual proxy (e.g. --proxy-options="http=localhost:321 ftp=localhost:4324")'
|
|
87
|
+
)
|
|
88
|
+
})
|
|
89
|
+
it('should parse socks proxy', () => {
|
|
90
|
+
expect(ParseProxy('socks', { socksProxy: 'localhost:213' })).toEqual({
|
|
91
|
+
proxyType: 'socks',
|
|
92
|
+
proxyOptions: {
|
|
93
|
+
socksProxy: 'localhost:213',
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
it('should parse socks proxy version', () => {
|
|
98
|
+
expect(
|
|
99
|
+
ParseProxy('socks', { socksProxy: 'localhost:213', socksVersion: 5 })
|
|
100
|
+
).toEqual({
|
|
101
|
+
proxyType: 'socks',
|
|
102
|
+
proxyOptions: {
|
|
103
|
+
socksProxy: 'localhost:213',
|
|
104
|
+
socksVersion: 5,
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
expect(
|
|
108
|
+
ParseProxy('socks', { socksProxy: 'localhost:213', socksVersion: '5' })
|
|
109
|
+
).toEqual({
|
|
110
|
+
proxyType: 'socks',
|
|
111
|
+
proxyOptions: {
|
|
112
|
+
socksProxy: 'localhost:213',
|
|
113
|
+
socksVersion: 5,
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
it('should throw if no socks proxy url was given', () => {
|
|
118
|
+
expect(() => ParseProxy('socks')).toThrowError(
|
|
119
|
+
'Proxy options were not passed to socks proxy (e.g. --proxy-options="socksProxy=localhost:321")'
|
|
120
|
+
)
|
|
121
|
+
expect(() => ParseProxy('socks', {})).toThrowError(
|
|
122
|
+
'Proxy options were not passed to socks proxy (e.g. --proxy-options="socksProxy=localhost:321")'
|
|
123
|
+
)
|
|
124
|
+
})
|
|
125
|
+
it('should throw if a non-number was passed as socks version', () => {
|
|
126
|
+
expect(() =>
|
|
127
|
+
ParseProxy('socks', { socksProxy: 'localhost:434', socksVersion: 'test' })
|
|
128
|
+
).toThrowError(
|
|
129
|
+
'Proxy socks version is invalid (e.g. --proxy-options="socksProxy=localhost:321 socksVersion=5")'
|
|
130
|
+
)
|
|
131
|
+
})
|
|
132
|
+
it('should throw if an invalid proxy type was passed', () => {
|
|
133
|
+
// @ts-expect-error intentionally invalid type
|
|
134
|
+
expect(() => ParseProxy('invalid')).toThrowError(
|
|
135
|
+
'An unknown proxy type was passed, use one of: direct, system, manual, socks or pac (e.g. --proxy-type="direct")'
|
|
136
|
+
)
|
|
137
|
+
})
|
|
138
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
|
|
18
|
+
import Satisfies from '../versioner'
|
|
19
|
+
|
|
20
|
+
describe('semantic versioner', () => {
|
|
21
|
+
it('should return `undefined` for exact version match', () => {
|
|
22
|
+
expect(Satisfies('2.1', '2.1')).toBeUndefined()
|
|
23
|
+
})
|
|
24
|
+
it('should return a runner upgrade warning for upper minor version mismatch', () => {
|
|
25
|
+
expect(Satisfies('2.1', '2.0')).toEqual(
|
|
26
|
+
'runner is older than project file, in case of issues upgrade the runner using: `npm i -g selenium-side-runner@latest`'
|
|
27
|
+
)
|
|
28
|
+
})
|
|
29
|
+
it('should return an IDE upgrade warning for lower minor version mismatch', () => {
|
|
30
|
+
expect(Satisfies('2.1', '2.2')).toEqual(
|
|
31
|
+
'project file is older than recommended, in case of issues upgrade the project via the IDE'
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
it('should throw a runner upgrade error for upper major version mismatch', () => {
|
|
35
|
+
expect(() => Satisfies('2.1', '1.1')).toThrow(
|
|
36
|
+
'runner is too old to run the project file, upgrade the runner using: `npm i -g selenium-side-runner@latest`'
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
it('should throw an IDE upgrade error for lower major version mismatch', () => {
|
|
40
|
+
expect(() => Satisfies('2.1', '3.1')).toThrow(
|
|
41
|
+
'project file is too old for the runner, upgrade the project via the IDE'
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
})
|
package/src/bin.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
|
+
// or more contributor license agreements. See the NOTICE file
|
|
5
|
+
// distributed with this work for additional information
|
|
6
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
7
|
+
// to you under the Apache License, Version 2.0 (the
|
|
8
|
+
// "License"); you may not use this file except in compliance
|
|
9
|
+
// with the License. You may obtain a copy of the License at
|
|
10
|
+
//
|
|
11
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
//
|
|
13
|
+
// Unless required by applicable law or agreed to in writing,
|
|
14
|
+
// software distributed under the License is distributed on an
|
|
15
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
// KIND, either express or implied. See the License for the
|
|
17
|
+
// specific language governing permissions and limitations
|
|
18
|
+
// under the License.
|
|
19
|
+
|
|
20
|
+
import os from 'os'
|
|
21
|
+
import path from 'path'
|
|
22
|
+
import crypto from 'crypto'
|
|
23
|
+
import util from 'util'
|
|
24
|
+
import { Command } from 'commander'
|
|
25
|
+
import Capabilities from './capabilities'
|
|
26
|
+
import Config from './config'
|
|
27
|
+
import ParseProxy from './proxy'
|
|
28
|
+
import { Configuration, ProxyInputOptions, SideRunnerAPI } from './types'
|
|
29
|
+
import { spawn } from 'child_process'
|
|
30
|
+
|
|
31
|
+
const isWindows = os.platform() === 'win32'
|
|
32
|
+
|
|
33
|
+
const metadata = require('../package.json')
|
|
34
|
+
|
|
35
|
+
const DEFAULT_TIMEOUT = 15000
|
|
36
|
+
|
|
37
|
+
process.title = metadata.name
|
|
38
|
+
|
|
39
|
+
const program: SideRunnerAPI = new Command() as SideRunnerAPI
|
|
40
|
+
program
|
|
41
|
+
.usage(
|
|
42
|
+
'[options] your-project-glob-here-*.side [variadic-project-globs-*.side]'
|
|
43
|
+
)
|
|
44
|
+
.version(metadata.version)
|
|
45
|
+
.option('--base-url [url]', 'Override the base URL that was set in the IDE')
|
|
46
|
+
.option('-c, --capabilities [list]', 'Webdriver capabilities')
|
|
47
|
+
.option('-s, --server [url]', 'Webdriver remote server')
|
|
48
|
+
.option('-p, --params [list]', 'General parameters')
|
|
49
|
+
.option(
|
|
50
|
+
'-f, --filter [string]',
|
|
51
|
+
'Run suites matching name, takes a regex without slashes, eg (^(hello|goodbye).*$)'
|
|
52
|
+
)
|
|
53
|
+
.option(
|
|
54
|
+
'-w, --max-workers [number]',
|
|
55
|
+
`Maximum amount of workers that will run your tests, defaults to number of cores`,
|
|
56
|
+
(str) => parseInt(str),
|
|
57
|
+
os.cpus().length
|
|
58
|
+
)
|
|
59
|
+
.option(
|
|
60
|
+
'-t, --timeout [number]',
|
|
61
|
+
`The maximimum amount of time, in milliseconds, to spend attempting to locate an element. (default: ${DEFAULT_TIMEOUT})`,
|
|
62
|
+
(str) => parseInt(str),
|
|
63
|
+
DEFAULT_TIMEOUT
|
|
64
|
+
)
|
|
65
|
+
.option(
|
|
66
|
+
'-x, --proxy-type [type]',
|
|
67
|
+
'Type of proxy to use (one of: direct, manual, pac, socks, system)'
|
|
68
|
+
)
|
|
69
|
+
.option(
|
|
70
|
+
'-y, --proxy-options [list]',
|
|
71
|
+
'Proxy options to pass, for use with manual, pac and socks proxies'
|
|
72
|
+
)
|
|
73
|
+
.option(
|
|
74
|
+
'-n, --config-file [filepath]',
|
|
75
|
+
'Use specified YAML file for configuration. (default: .side.yml)'
|
|
76
|
+
)
|
|
77
|
+
.option(
|
|
78
|
+
'-o, --output-directory [directory]',
|
|
79
|
+
'Write test results to files, format is defined by --output-format'
|
|
80
|
+
)
|
|
81
|
+
.option(
|
|
82
|
+
'-f, --force',
|
|
83
|
+
"Forcibly run the project, regardless of project's version"
|
|
84
|
+
)
|
|
85
|
+
.option('-d, --debug', 'Print debug logs')
|
|
86
|
+
|
|
87
|
+
program.parse()
|
|
88
|
+
|
|
89
|
+
if (!program.args.length) {
|
|
90
|
+
program.outputHelp()
|
|
91
|
+
// eslint-disable-next-line no-process-exit
|
|
92
|
+
process.exit(1)
|
|
93
|
+
}
|
|
94
|
+
const options = program.opts()
|
|
95
|
+
const configuration: Configuration = {
|
|
96
|
+
baseUrl: '',
|
|
97
|
+
capabilities: {
|
|
98
|
+
browserName: 'chrome',
|
|
99
|
+
},
|
|
100
|
+
debug: options.debug,
|
|
101
|
+
filter: '.*',
|
|
102
|
+
force: options.force,
|
|
103
|
+
maxWorkers: options.maxWorkers,
|
|
104
|
+
params: {},
|
|
105
|
+
// Convert all project paths into absolute paths
|
|
106
|
+
projects: program.args.map((arg) => {
|
|
107
|
+
if (path.isAbsolute(arg)) return arg
|
|
108
|
+
return path.join(process.cwd(), arg)
|
|
109
|
+
}),
|
|
110
|
+
proxyOptions: {},
|
|
111
|
+
runId: crypto.randomBytes(16).toString('hex'),
|
|
112
|
+
path: path.join(__dirname, '../../'),
|
|
113
|
+
server: '',
|
|
114
|
+
timeout: options.timeout,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const confPath = options.configFile || '.side.yml'
|
|
118
|
+
const configFilePath = path.isAbsolute(confPath)
|
|
119
|
+
? confPath
|
|
120
|
+
: path.join(process.cwd(), confPath)
|
|
121
|
+
try {
|
|
122
|
+
Object.assign(configuration, Config.load(configFilePath))
|
|
123
|
+
} catch (e) {
|
|
124
|
+
options.debug && console.debug('Could not load ' + configFilePath)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (options.filter) {
|
|
128
|
+
configuration.filter = options.filter
|
|
129
|
+
}
|
|
130
|
+
configuration.server = options.server ? options.server : configuration.server
|
|
131
|
+
|
|
132
|
+
if (options.capabilities) {
|
|
133
|
+
try {
|
|
134
|
+
configuration.capabilities = Capabilities.parseString(options.capabilities)
|
|
135
|
+
} catch (e) {
|
|
136
|
+
options.debug && console.debug('Failed to parse inline capabilities')
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (options.params) {
|
|
141
|
+
try {
|
|
142
|
+
configuration.params = Capabilities.parseString(options.params)
|
|
143
|
+
} catch (e) {
|
|
144
|
+
options.debug && console.debug('Failed to parse additional params')
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (options.proxyType) {
|
|
149
|
+
try {
|
|
150
|
+
let opts
|
|
151
|
+
if (options.proxyType === 'manual' || options.proxyType === 'socks') {
|
|
152
|
+
opts = Capabilities.parseString(options.proxyOptions as string)
|
|
153
|
+
}
|
|
154
|
+
const proxy = ParseProxy(options.proxyType, opts as ProxyInputOptions)
|
|
155
|
+
Object.assign(configuration.capabilities, proxy)
|
|
156
|
+
} catch (e) {
|
|
157
|
+
console.error((e as Error).message)
|
|
158
|
+
// eslint-disable-next-line no-process-exit
|
|
159
|
+
process.exit(1)
|
|
160
|
+
}
|
|
161
|
+
} else if (configuration.proxyType) {
|
|
162
|
+
try {
|
|
163
|
+
const proxy = ParseProxy(
|
|
164
|
+
configuration.proxyType,
|
|
165
|
+
configuration.proxyOptions
|
|
166
|
+
)
|
|
167
|
+
Object.assign(configuration.capabilities, proxy)
|
|
168
|
+
} catch (e) {
|
|
169
|
+
console.error((e as Error).message)
|
|
170
|
+
// eslint-disable-next-line no-process-exit
|
|
171
|
+
process.exit(1)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
configuration.baseUrl = options.baseUrl
|
|
176
|
+
? options.baseUrl
|
|
177
|
+
: configuration.baseUrl
|
|
178
|
+
|
|
179
|
+
options.debug && console.debug(util.inspect(configuration))
|
|
180
|
+
|
|
181
|
+
const jestExecutable = isWindows ? 'jest.cmd' : 'jest'
|
|
182
|
+
spawn(
|
|
183
|
+
path.join(__dirname, '..', 'node_modules', '.bin', jestExecutable),
|
|
184
|
+
[
|
|
185
|
+
'--config=' + path.join(__dirname, '..', 'jest.config.js'),
|
|
186
|
+
'--maxConcurrency=' + configuration.maxWorkers,
|
|
187
|
+
'--runTestsByPath',
|
|
188
|
+
path.join(__dirname, 'main.test.js'),
|
|
189
|
+
],
|
|
190
|
+
{
|
|
191
|
+
env: {
|
|
192
|
+
...process.env,
|
|
193
|
+
SE_CONFIGURATION: JSON.stringify(configuration),
|
|
194
|
+
},
|
|
195
|
+
shell: true,
|
|
196
|
+
stdio: 'inherit',
|
|
197
|
+
}
|
|
198
|
+
).on('exit', (code) => {
|
|
199
|
+
// This is my bin, my process
|
|
200
|
+
// eslint-disable-next-line no-process-exit
|
|
201
|
+
process.exit(code as number)
|
|
202
|
+
})
|