@wdio/browser-runner 8.0.2 → 8.0.4
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/build/browser/driver.d.ts.map +1 -1
- package/build/browser/driver.js +23 -9
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -2
- package/build/vite/server.d.ts.map +1 -1
- package/build/vite/server.js +12 -0
- package/package.json +7 -7
- package/build/browser/commands/index.d.ts +0 -3
- package/build/browser/commands/index.d.ts.map +0 -1
- package/build/browser/commands/index.js +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/browser/driver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/browser/driver.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,OAAO,WAAW;;IAG5B,MAAM,CAAC,UAAU,CACb,MAAM,EAAE,GAAG,EACX,QAAQ,EAAE,KAAK,EACf,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACjD,cAAc,EAAE,GAAG;CAkJ1B"}
|
package/build/browser/driver.js
CHANGED
|
@@ -2,7 +2,6 @@ import stringify from 'fast-safe-stringify';
|
|
|
2
2
|
import { commands } from 'virtual:wdio';
|
|
3
3
|
import { webdriverMonad } from '@wdio/utils';
|
|
4
4
|
import { getEnvironmentVars } from 'webdriver';
|
|
5
|
-
import browserCommands from './commands/index.js';
|
|
6
5
|
import { MESSAGE_TYPES } from '../constants.js';
|
|
7
6
|
const COMMAND_TIMEOUT = 30 * 1000; // 30s
|
|
8
7
|
const CONSOLE_METHODS = ['log', 'info', 'warn', 'error', 'debug'];
|
|
@@ -25,14 +24,22 @@ export default class ProxyDriver {
|
|
|
25
24
|
socket.addEventListener('message', this.#handleServerMessage.bind(this));
|
|
26
25
|
let commandId = 0;
|
|
27
26
|
const environmentPrototype = getEnvironmentVars(params);
|
|
28
|
-
|
|
27
|
+
// have debug command
|
|
28
|
+
const commandsProcessedInNodeWorld = [...commands, 'debug'];
|
|
29
|
+
const protocolCommands = commandsProcessedInNodeWorld.reduce((prev, commandName) => {
|
|
30
|
+
const isDebugCommand = commandName === 'debug';
|
|
29
31
|
prev[commandName] = {
|
|
30
32
|
value: async (...args) => {
|
|
31
33
|
if (socket.readyState !== 1) {
|
|
32
34
|
await connectPromise;
|
|
33
35
|
}
|
|
34
36
|
commandId++;
|
|
35
|
-
|
|
37
|
+
/**
|
|
38
|
+
* print information which command is executed (except for debug commands)
|
|
39
|
+
*/
|
|
40
|
+
console.log(...(isDebugCommand
|
|
41
|
+
? ['[WDIO] %cDebug Mode Enabled', 'background: #ea5906; color: #fff; padding: 3px; border-radius: 5px;']
|
|
42
|
+
: [`[WDIO] ${(new Date()).toISOString()} - id: ${commandId} - COMMAND: ${commandName}(${args.join(', ')})`]));
|
|
36
43
|
socket.send(JSON.stringify(this.#commandRequest({
|
|
37
44
|
commandName,
|
|
38
45
|
cid,
|
|
@@ -40,13 +47,20 @@ export default class ProxyDriver {
|
|
|
40
47
|
args
|
|
41
48
|
})));
|
|
42
49
|
return new Promise((resolve, reject) => {
|
|
43
|
-
|
|
50
|
+
let commandTimeout;
|
|
51
|
+
if (!isDebugCommand) {
|
|
52
|
+
commandTimeout = setTimeout(() => reject(new Error(`Command "${commandName}" timed out`)), COMMAND_TIMEOUT);
|
|
53
|
+
}
|
|
44
54
|
this.#commandMessages.set(commandId.toString(), { resolve, reject, commandTimeout });
|
|
45
55
|
});
|
|
46
56
|
}
|
|
47
57
|
};
|
|
48
58
|
return prev;
|
|
49
59
|
}, {});
|
|
60
|
+
/**
|
|
61
|
+
* handle debug command on the server side
|
|
62
|
+
*/
|
|
63
|
+
delete userPrototype.debug;
|
|
50
64
|
const prototype = {
|
|
51
65
|
/**
|
|
52
66
|
* custom protocol commands that communicate with Vite
|
|
@@ -59,11 +73,7 @@ export default class ProxyDriver {
|
|
|
59
73
|
/**
|
|
60
74
|
* unmodified WebdriverIO commands
|
|
61
75
|
*/
|
|
62
|
-
...userPrototype
|
|
63
|
-
/**
|
|
64
|
-
* custom browser specific commands
|
|
65
|
-
*/
|
|
66
|
-
...browserCommands
|
|
76
|
+
...userPrototype
|
|
67
77
|
};
|
|
68
78
|
prototype.emit = { writable: true, value: () => { } };
|
|
69
79
|
prototype.on = { writable: true, value: () => { } };
|
|
@@ -87,8 +97,12 @@ export default class ProxyDriver {
|
|
|
87
97
|
console.log(`[WDIO] ${(new Date()).toISOString()} - id: ${value.id} - ERROR: ${JSON.stringify(value.result)}`);
|
|
88
98
|
return commandMessage.reject(value.error);
|
|
89
99
|
}
|
|
100
|
+
if (commandMessage.commandTimeout) {
|
|
101
|
+
clearTimeout(commandMessage.commandTimeout);
|
|
102
|
+
}
|
|
90
103
|
console.log(`[WDIO] ${(new Date()).toISOString()} - id: ${value.id} - RESULT: ${JSON.stringify(value.result)}`);
|
|
91
104
|
commandMessage.resolve(value.result);
|
|
105
|
+
this.#commandMessages.delete(value.id);
|
|
92
106
|
}
|
|
93
107
|
catch (err) {
|
|
94
108
|
console.error(`Failed handling command socket message "${err.message}"`);
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAIzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAK1C,OAAO,KAAK,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAIjF,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;;IAK9C,OAAO,CAAC,OAAO;IACf,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU;gBAD7B,OAAO,EAAE,0BAA0B,EACjC,OAAO,EAAE,OAAO,CAAC,UAAU;IAYzC;;OAEG;IACG,UAAU;IAYhB,GAAG,CAAE,OAAO,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAIzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAK1C,OAAO,KAAK,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAIjF,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;;IAK9C,OAAO,CAAC,OAAO;IACf,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU;gBAD7B,OAAO,EAAE,0BAA0B,EACjC,OAAO,EAAE,OAAO,CAAC,UAAU;IAYzC;;OAEG;IACG,UAAU;IAYhB,GAAG,CAAE,OAAO,EAAE,OAAO;IAyCrB;;;;OAIG;IACG,QAAQ;CAIjB;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,oBAAqB,SAAQ,0BAA0B;SAAG;KACvE;CACJ"}
|
package/build/index.js
CHANGED
|
@@ -49,14 +49,19 @@ export default class BrowserRunner extends LocalRunner {
|
|
|
49
49
|
sessionId: payload.content.sessionId,
|
|
50
50
|
injectGlobals: payload.content.injectGlobals
|
|
51
51
|
});
|
|
52
|
-
|
|
52
|
+
const browser = await attach({
|
|
53
53
|
...this.#config,
|
|
54
54
|
...payload.content,
|
|
55
55
|
options: {
|
|
56
56
|
...this.#config,
|
|
57
57
|
...payload.content
|
|
58
58
|
}
|
|
59
|
-
})
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* propagate debug state to the worker
|
|
62
|
+
*/
|
|
63
|
+
browser.on('debugState', (state) => worker.postMessage('switchDebugState', state));
|
|
64
|
+
BROWSER_POOL.set(payload.cid, browser);
|
|
60
65
|
}
|
|
61
66
|
if (payload.name === 'sessionEnded') {
|
|
62
67
|
SESSIONS.delete(payload.cid);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAa,MAAM,IAAI,CAAA;AAG/C,OAAO,EAA+B,YAAY,EAAE,MAAM,MAAM,CAAA;AAchE,qBAAa,UAAU;;IAOnB,IAAI,YAAY,gCAEf;IAED,IAAI,MAAM,0BAET;gBAEY,OAAO,EAAE,WAAW,CAAC,oBAAoB;IAiBhD,KAAK;IAuCL,KAAK;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAa,MAAM,IAAI,CAAA;AAG/C,OAAO,EAA+B,YAAY,EAAE,MAAM,MAAM,CAAA;AAchE,qBAAa,UAAU;;IAOnB,IAAI,YAAY,gCAEf;IAED,IAAI,MAAM,0BAET;gBAEY,OAAO,EAAE,WAAW,CAAC,oBAAoB;IAiBhD,KAAK;IAuCL,KAAK;CA8Gd"}
|
package/build/vite/server.js
CHANGED
|
@@ -132,8 +132,20 @@ export class ViteServer {
|
|
|
132
132
|
return ws.send(JSON.stringify(this.#commandResponse({ id: payload.id, error })));
|
|
133
133
|
}
|
|
134
134
|
try {
|
|
135
|
+
/**
|
|
136
|
+
* emit debug state to be enabled to runner so it can be propagated to the worker
|
|
137
|
+
*/
|
|
138
|
+
if (payload.commandName === 'debug') {
|
|
139
|
+
browser.emit('debugState', true);
|
|
140
|
+
}
|
|
135
141
|
const result = await browser[payload.commandName](...payload.args);
|
|
136
142
|
const resultMsg = JSON.stringify(this.#commandResponse({ id: payload.id, result }));
|
|
143
|
+
/**
|
|
144
|
+
* emit debug state to be disabled to runner so it can be propagated to the worker
|
|
145
|
+
*/
|
|
146
|
+
if (payload.commandName === 'debug') {
|
|
147
|
+
browser.emit('debugState', false);
|
|
148
|
+
}
|
|
137
149
|
log.info(`Return command result: ${resultMsg}`);
|
|
138
150
|
return ws.send(resultMsg);
|
|
139
151
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browser-runner",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.4",
|
|
4
4
|
"description": "A WebdriverIO runner to run unit tests tests in the browser.",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-browser-runner",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
|
32
32
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
33
33
|
"@types/mocha": "^10.0.0",
|
|
34
|
-
"@wdio/globals": "8.0.
|
|
35
|
-
"@wdio/local-runner": "8.0.
|
|
34
|
+
"@wdio/globals": "8.0.4",
|
|
35
|
+
"@wdio/local-runner": "8.0.4",
|
|
36
36
|
"@wdio/logger": "8.0.0",
|
|
37
37
|
"@wdio/mocha-framework": "8.0.2",
|
|
38
38
|
"@wdio/protocols": "8.0.0",
|
|
39
|
-
"@wdio/runner": "8.0.
|
|
39
|
+
"@wdio/runner": "8.0.4",
|
|
40
40
|
"@wdio/types": "8.0.0",
|
|
41
41
|
"@wdio/utils": "8.0.2",
|
|
42
42
|
"deepmerge-ts": "^4.2.2",
|
|
43
|
-
"expect-webdriverio": "^4.0.
|
|
43
|
+
"expect-webdriverio": "^4.0.1",
|
|
44
44
|
"fast-safe-stringify": "^2.1.1",
|
|
45
45
|
"get-port": "^6.1.2",
|
|
46
46
|
"import-meta-resolve": "^2.1.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vite": "^3.1.7",
|
|
49
49
|
"vite-plugin-top-level-await": "^1.2.1",
|
|
50
50
|
"webdriver": "8.0.2",
|
|
51
|
-
"webdriverio": "8.0.
|
|
51
|
+
"webdriverio": "8.0.4",
|
|
52
52
|
"ws": "^8.10.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/ws": "^8.5.3"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3e59b46e07fe878dd9ff57d746f698edcb13d94f"
|
|
64
64
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/commands/index.ts"],"names":[],"mappings":";AAGA,wBAG4C"}
|