@testring/plugin-selenium-driver 0.7.0 → 0.7.2
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/dist/plugin/index.js +1 -59
- package/package.json +6 -7
- package/src/plugin/index.ts +1 -77
package/dist/plugin/index.js
CHANGED
|
@@ -16,7 +16,6 @@ const deepmerge = require("deepmerge");
|
|
|
16
16
|
const child_process_1 = require("@testring/child-process");
|
|
17
17
|
const logger_1 = require("@testring/logger");
|
|
18
18
|
const dwnld_collector_crx_1 = require("@testring/dwnld-collector-crx");
|
|
19
|
-
const devtool_extension_1 = require("@testring/devtool-extension");
|
|
20
19
|
const code_coverage_client_1 = require("@nullcc/code-coverage-client");
|
|
21
20
|
const webdriver_1 = require("webdriver");
|
|
22
21
|
const DEFAULT_CONFIG = {
|
|
@@ -63,69 +62,12 @@ class SeleniumPlugin {
|
|
|
63
62
|
}
|
|
64
63
|
this.initIntervals();
|
|
65
64
|
}
|
|
66
|
-
getDevelopmentConfigAdditions() {
|
|
67
|
-
return {
|
|
68
|
-
capabilities: {
|
|
69
|
-
'goog:chromeOptions': {
|
|
70
|
-
args: [`load-extension=${devtool_extension_1.absoluteExtensionPath}`],
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
65
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
76
66
|
createConfig(config) {
|
|
77
67
|
var _a, _b;
|
|
78
|
-
|
|
68
|
+
const mergedConfig = deepmerge.all([DEFAULT_CONFIG, config], {
|
|
79
69
|
clone: true,
|
|
80
70
|
});
|
|
81
|
-
if (mergedConfig.recorderExtension) {
|
|
82
|
-
mergedConfig = deepmerge.all([mergedConfig, this.getDevelopmentConfigAdditions()], {
|
|
83
|
-
customMerge: (mergeKey) => {
|
|
84
|
-
if (mergeKey === 'goog:chromeOptions') {
|
|
85
|
-
return (itemA, itemB) => {
|
|
86
|
-
if (!itemA.args || !itemB.args) {
|
|
87
|
-
return deepmerge(itemA, itemB);
|
|
88
|
-
}
|
|
89
|
-
const res = {};
|
|
90
|
-
res.args = deepmerge(itemA.args, itemB.args);
|
|
91
|
-
let ext = res.args.filter((argItem) => argItem.startsWith('load-extension'));
|
|
92
|
-
if (ext.length === 2) {
|
|
93
|
-
ext = [
|
|
94
|
-
`load-extension=${ext[0]
|
|
95
|
-
.split('=', 2)
|
|
96
|
-
.pop()},${ext[1]
|
|
97
|
-
.split('=', 2)
|
|
98
|
-
.pop()}`,
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
res.args = [
|
|
102
|
-
...ext,
|
|
103
|
-
...res.args.filter((argItem) => !argItem.startsWith('load-extension')),
|
|
104
|
-
];
|
|
105
|
-
Object.keys(itemA).forEach((key) => {
|
|
106
|
-
if (key === 'args') {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (itemB[key] !== undefined) {
|
|
110
|
-
res[key] = deepmerge(itemA[key], itemB[key]);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
res[key] = itemA[key];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
Object.keys(itemB).forEach((key) => {
|
|
117
|
-
if (key === 'args' ||
|
|
118
|
-
res[key] !== undefined) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
res[key] = itemB[key];
|
|
122
|
-
});
|
|
123
|
-
return res;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
71
|
if (!mergedConfig.hostname && mergedConfig.host) {
|
|
130
72
|
mergedConfig.hostname = mergedConfig.host;
|
|
131
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testring/plugin-selenium-driver",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"typings": "./src/index.ts",
|
|
6
6
|
"repository": {
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@nullcc/code-coverage-client": "1.4.2",
|
|
14
|
-
"@testring/child-process": "0.7.
|
|
15
|
-
"@testring/
|
|
16
|
-
"@testring/
|
|
17
|
-
"@testring/
|
|
18
|
-
"@testring/
|
|
19
|
-
"@testring/types": "0.7.0",
|
|
14
|
+
"@testring/child-process": "0.7.2",
|
|
15
|
+
"@testring/dwnld-collector-crx": "0.7.2",
|
|
16
|
+
"@testring/logger": "0.7.2",
|
|
17
|
+
"@testring/plugin-api": "0.7.2",
|
|
18
|
+
"@testring/types": "0.7.2",
|
|
20
19
|
"@types/deepmerge": "2.2.3",
|
|
21
20
|
"@types/node": "22.8.5",
|
|
22
21
|
"@wdio/types": "9.2.2",
|
package/src/plugin/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ import * as deepmerge from 'deepmerge';
|
|
|
9
9
|
import {spawn} from '@testring/child-process';
|
|
10
10
|
import {loggerClient} from '@testring/logger';
|
|
11
11
|
import {getCrxBase64} from '@testring/dwnld-collector-crx';
|
|
12
|
-
import {absoluteExtensionPath} from '@testring/devtool-extension';
|
|
13
12
|
import {CDPCoverageCollector} from '@nullcc/code-coverage-client';
|
|
14
13
|
|
|
15
14
|
import type {Cookie} from '@wdio/protocols';
|
|
@@ -92,92 +91,17 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {
|
|
|
92
91
|
this.initIntervals();
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
private getDevelopmentConfigAdditions(): Partial<SeleniumPluginConfig> {
|
|
96
|
-
return {
|
|
97
|
-
capabilities: {
|
|
98
|
-
'goog:chromeOptions': {
|
|
99
|
-
args: [`load-extension=${absoluteExtensionPath}`],
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
} as any;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
94
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
106
95
|
private createConfig(
|
|
107
96
|
config: Partial<SeleniumPluginConfig>,
|
|
108
97
|
): SeleniumPluginConfig {
|
|
109
|
-
|
|
98
|
+
const mergedConfig = deepmerge.all<SeleniumPluginConfig>(
|
|
110
99
|
[DEFAULT_CONFIG, config],
|
|
111
100
|
{
|
|
112
101
|
clone: true,
|
|
113
102
|
},
|
|
114
103
|
);
|
|
115
104
|
|
|
116
|
-
if (mergedConfig.recorderExtension) {
|
|
117
|
-
mergedConfig = deepmerge.all<SeleniumPluginConfig>(
|
|
118
|
-
[mergedConfig, this.getDevelopmentConfigAdditions()],
|
|
119
|
-
{
|
|
120
|
-
customMerge: (mergeKey) => {
|
|
121
|
-
if (mergeKey === 'goog:chromeOptions') {
|
|
122
|
-
return (itemA, itemB) => {
|
|
123
|
-
if (!itemA.args || !itemB.args) {
|
|
124
|
-
return deepmerge(itemA, itemB);
|
|
125
|
-
}
|
|
126
|
-
const res: Record<string, any> = {};
|
|
127
|
-
res.args = deepmerge(itemA.args, itemB.args);
|
|
128
|
-
let ext: string[] = res.args.filter(
|
|
129
|
-
(argItem: string) =>
|
|
130
|
-
argItem.startsWith('load-extension'),
|
|
131
|
-
);
|
|
132
|
-
if (ext.length === 2) {
|
|
133
|
-
ext = [
|
|
134
|
-
`load-extension=${ext[0]
|
|
135
|
-
.split('=', 2)
|
|
136
|
-
.pop()},${ext[1]
|
|
137
|
-
.split('=', 2)
|
|
138
|
-
.pop()}`,
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
res.args = [
|
|
142
|
-
...ext,
|
|
143
|
-
...res.args.filter(
|
|
144
|
-
(argItem: string) =>
|
|
145
|
-
!argItem.startsWith(
|
|
146
|
-
'load-extension',
|
|
147
|
-
),
|
|
148
|
-
),
|
|
149
|
-
];
|
|
150
|
-
Object.keys(itemA).forEach((key) => {
|
|
151
|
-
if (key === 'args') {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (itemB[key] !== undefined) {
|
|
155
|
-
res[key] = deepmerge(
|
|
156
|
-
itemA[key],
|
|
157
|
-
itemB[key],
|
|
158
|
-
);
|
|
159
|
-
} else {
|
|
160
|
-
res[key] = itemA[key];
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
Object.keys(itemB).forEach((key) => {
|
|
164
|
-
if (
|
|
165
|
-
key === 'args' ||
|
|
166
|
-
res[key] !== undefined
|
|
167
|
-
) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
res[key] = itemB[key];
|
|
172
|
-
});
|
|
173
|
-
return res;
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
105
|
if (!mergedConfig.hostname && mergedConfig.host) {
|
|
182
106
|
mergedConfig.hostname = mergedConfig.host;
|
|
183
107
|
}
|