@lvce-editor/test-with-playwright-worker 12.1.0 → 13.0.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/dist/workerMain.js +100 -91
- package/package.json +2 -2
package/dist/workerMain.js
CHANGED
|
@@ -377,56 +377,14 @@ const IpcChildWithNodeWorker$1 = {
|
|
|
377
377
|
wrap: wrap$b
|
|
378
378
|
};
|
|
379
379
|
|
|
380
|
-
const Two = '2.0';
|
|
381
|
-
const create$4 = (method, params) => {
|
|
382
|
-
return {
|
|
383
|
-
jsonrpc: Two,
|
|
384
|
-
method,
|
|
385
|
-
params
|
|
386
|
-
};
|
|
387
|
-
};
|
|
380
|
+
const Two$1 = '2.0';
|
|
388
381
|
const callbacks = Object.create(null);
|
|
389
|
-
const set$1 = (id, fn) => {
|
|
390
|
-
callbacks[id] = fn;
|
|
391
|
-
};
|
|
392
382
|
const get$1 = id => {
|
|
393
383
|
return callbacks[id];
|
|
394
384
|
};
|
|
395
385
|
const remove = id => {
|
|
396
386
|
delete callbacks[id];
|
|
397
387
|
};
|
|
398
|
-
let id = 0;
|
|
399
|
-
const create$3 = () => {
|
|
400
|
-
return ++id;
|
|
401
|
-
};
|
|
402
|
-
const registerPromise = () => {
|
|
403
|
-
const id = create$3();
|
|
404
|
-
const {
|
|
405
|
-
resolve,
|
|
406
|
-
promise
|
|
407
|
-
} = Promise.withResolvers();
|
|
408
|
-
set$1(id, resolve);
|
|
409
|
-
return {
|
|
410
|
-
id,
|
|
411
|
-
promise
|
|
412
|
-
};
|
|
413
|
-
};
|
|
414
|
-
const create$2 = (method, params) => {
|
|
415
|
-
const {
|
|
416
|
-
id,
|
|
417
|
-
promise
|
|
418
|
-
} = registerPromise();
|
|
419
|
-
const message = {
|
|
420
|
-
jsonrpc: Two,
|
|
421
|
-
method,
|
|
422
|
-
params,
|
|
423
|
-
id
|
|
424
|
-
};
|
|
425
|
-
return {
|
|
426
|
-
message,
|
|
427
|
-
promise
|
|
428
|
-
};
|
|
429
|
-
};
|
|
430
388
|
class JsonRpcError extends Error {
|
|
431
389
|
constructor(message) {
|
|
432
390
|
super(message);
|
|
@@ -622,7 +580,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
622
580
|
};
|
|
623
581
|
const create$1 = (id, error) => {
|
|
624
582
|
return {
|
|
625
|
-
jsonrpc: Two,
|
|
583
|
+
jsonrpc: Two$1,
|
|
626
584
|
id,
|
|
627
585
|
error
|
|
628
586
|
};
|
|
@@ -635,7 +593,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
635
593
|
};
|
|
636
594
|
const create = (message, result) => {
|
|
637
595
|
return {
|
|
638
|
-
jsonrpc: Two,
|
|
596
|
+
jsonrpc: Two$1,
|
|
639
597
|
id: message.id,
|
|
640
598
|
result: result ?? null
|
|
641
599
|
};
|
|
@@ -646,7 +604,7 @@ const getSuccessResponse = (message, result) => {
|
|
|
646
604
|
};
|
|
647
605
|
const getErrorResponseSimple = (id, error) => {
|
|
648
606
|
return {
|
|
649
|
-
jsonrpc: Two,
|
|
607
|
+
jsonrpc: Two$1,
|
|
650
608
|
id,
|
|
651
609
|
error: {
|
|
652
610
|
code: Custom,
|
|
@@ -733,29 +691,6 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
733
691
|
}
|
|
734
692
|
throw new JsonRpcError('unexpected message');
|
|
735
693
|
};
|
|
736
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
737
|
-
const {
|
|
738
|
-
message,
|
|
739
|
-
promise
|
|
740
|
-
} = create$2(method, params);
|
|
741
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
742
|
-
ipc.sendAndTransfer(message);
|
|
743
|
-
} else {
|
|
744
|
-
ipc.send(message);
|
|
745
|
-
}
|
|
746
|
-
const responseMessage = await promise;
|
|
747
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
748
|
-
};
|
|
749
|
-
const send = (transport, method, ...params) => {
|
|
750
|
-
const message = create$4(method, params);
|
|
751
|
-
transport.send(message);
|
|
752
|
-
};
|
|
753
|
-
const invoke = (ipc, method, ...params) => {
|
|
754
|
-
return invokeHelper(ipc, method, params, false);
|
|
755
|
-
};
|
|
756
|
-
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
757
|
-
return invokeHelper(ipc, method, params, true);
|
|
758
|
-
};
|
|
759
694
|
|
|
760
695
|
class CommandNotFoundError extends Error {
|
|
761
696
|
constructor(command) {
|
|
@@ -778,24 +713,87 @@ const execute = (command, ...args) => {
|
|
|
778
713
|
return fn(...args);
|
|
779
714
|
};
|
|
780
715
|
|
|
716
|
+
const Two = '2.0';
|
|
717
|
+
const create$s = (method, params) => {
|
|
718
|
+
return {
|
|
719
|
+
jsonrpc: Two,
|
|
720
|
+
method,
|
|
721
|
+
params
|
|
722
|
+
};
|
|
723
|
+
};
|
|
724
|
+
const create$r = (id, method, params) => {
|
|
725
|
+
const message = {
|
|
726
|
+
id,
|
|
727
|
+
jsonrpc: Two,
|
|
728
|
+
method,
|
|
729
|
+
params
|
|
730
|
+
};
|
|
731
|
+
return message;
|
|
732
|
+
};
|
|
733
|
+
let id = 0;
|
|
734
|
+
const create$q = () => {
|
|
735
|
+
return ++id;
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
739
|
+
|
|
740
|
+
const registerPromise = map => {
|
|
741
|
+
const id = create$q();
|
|
742
|
+
const {
|
|
743
|
+
promise,
|
|
744
|
+
resolve
|
|
745
|
+
} = Promise.withResolvers();
|
|
746
|
+
map[id] = resolve;
|
|
747
|
+
return {
|
|
748
|
+
id,
|
|
749
|
+
promise
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
// @ts-ignore
|
|
754
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
755
|
+
const {
|
|
756
|
+
id,
|
|
757
|
+
promise
|
|
758
|
+
} = registerPromise(callbacks);
|
|
759
|
+
const message = create$r(id, method, params);
|
|
760
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
761
|
+
ipc.sendAndTransfer(message);
|
|
762
|
+
} else {
|
|
763
|
+
ipc.send(message);
|
|
764
|
+
}
|
|
765
|
+
const responseMessage = await promise;
|
|
766
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
767
|
+
};
|
|
781
768
|
const createRpc = ipc => {
|
|
769
|
+
const callbacks = Object.create(null);
|
|
770
|
+
ipc._resolve = (id, response) => {
|
|
771
|
+
const fn = callbacks[id];
|
|
772
|
+
if (!fn) {
|
|
773
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
fn(response);
|
|
777
|
+
delete callbacks[id];
|
|
778
|
+
};
|
|
782
779
|
const rpc = {
|
|
780
|
+
async dispose() {
|
|
781
|
+
await ipc?.dispose();
|
|
782
|
+
},
|
|
783
|
+
invoke(method, ...params) {
|
|
784
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
785
|
+
},
|
|
786
|
+
invokeAndTransfer(method, ...params) {
|
|
787
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
788
|
+
},
|
|
783
789
|
// @ts-ignore
|
|
784
790
|
ipc,
|
|
785
791
|
/**
|
|
786
792
|
* @deprecated
|
|
787
793
|
*/
|
|
788
794
|
send(method, ...params) {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
invoke(method, ...params) {
|
|
792
|
-
return invoke(ipc, method, ...params);
|
|
793
|
-
},
|
|
794
|
-
invokeAndTransfer(method, ...params) {
|
|
795
|
-
return invokeAndTransfer(ipc, method, ...params);
|
|
796
|
-
},
|
|
797
|
-
async dispose() {
|
|
798
|
-
await ipc?.dispose();
|
|
795
|
+
const message = create$s(method, params);
|
|
796
|
+
ipc.send(message);
|
|
799
797
|
}
|
|
800
798
|
};
|
|
801
799
|
return rpc;
|
|
@@ -812,7 +810,7 @@ const logError = () => {
|
|
|
812
810
|
const handleMessage = event => {
|
|
813
811
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
814
812
|
const actualExecute = event?.target?.execute || execute;
|
|
815
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
813
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
816
814
|
};
|
|
817
815
|
const handleIpc = ipc => {
|
|
818
816
|
if ('addEventListener' in ipc) {
|
|
@@ -830,7 +828,7 @@ const listen = async (module, options) => {
|
|
|
830
828
|
const ipc = module.wrap(rawIpc);
|
|
831
829
|
return ipc;
|
|
832
830
|
};
|
|
833
|
-
const create$
|
|
831
|
+
const create$6 = async ({
|
|
834
832
|
commandMap
|
|
835
833
|
}) => {
|
|
836
834
|
// TODO create a commandMap per rpc instance
|
|
@@ -842,7 +840,7 @@ const create$7 = async ({
|
|
|
842
840
|
};
|
|
843
841
|
const NodeWorkerRpcClient = {
|
|
844
842
|
__proto__: null,
|
|
845
|
-
create: create$
|
|
843
|
+
create: create$6
|
|
846
844
|
};
|
|
847
845
|
|
|
848
846
|
const rpcs = Object.create(null);
|
|
@@ -944,21 +942,27 @@ const getTestState = (testOverlayState, text) => {
|
|
|
944
942
|
/**
|
|
945
943
|
* @param {string} absolutePath
|
|
946
944
|
* @param {number} port
|
|
945
|
+
* @param {boolean} traceFocus
|
|
947
946
|
*/
|
|
948
|
-
const getUrlFromTestFile = (absolutePath, port) => {
|
|
947
|
+
const getUrlFromTestFile = (absolutePath, port, traceFocus) => {
|
|
949
948
|
const baseName = basename(absolutePath);
|
|
950
949
|
const htmlFileName = baseName.slice(0, -'.js'.length) + '.html';
|
|
951
|
-
|
|
950
|
+
const baseUrl = `http://localhost:${port}/tests/${htmlFileName}`;
|
|
951
|
+
if (traceFocus) {
|
|
952
|
+
return `${baseUrl}?traceFocus=true`;
|
|
953
|
+
}
|
|
954
|
+
return baseUrl;
|
|
952
955
|
};
|
|
953
956
|
const runTest = async ({
|
|
954
957
|
page,
|
|
955
958
|
port,
|
|
956
959
|
test,
|
|
957
960
|
testSrc,
|
|
958
|
-
timeout
|
|
961
|
+
timeout,
|
|
962
|
+
traceFocus
|
|
959
963
|
}) => {
|
|
960
964
|
const start = performance.now();
|
|
961
|
-
const url = getUrlFromTestFile(test, port);
|
|
965
|
+
const url = getUrlFromTestFile(test, port, traceFocus);
|
|
962
966
|
await page.goto(url, {
|
|
963
967
|
waitUntil: 'networkidle'
|
|
964
968
|
});
|
|
@@ -993,7 +997,8 @@ const runTests = async ({
|
|
|
993
997
|
port,
|
|
994
998
|
tests,
|
|
995
999
|
testSrc,
|
|
996
|
-
timeout
|
|
1000
|
+
timeout,
|
|
1001
|
+
traceFocus
|
|
997
1002
|
}) => {
|
|
998
1003
|
let failed = 0;
|
|
999
1004
|
let skipped = 0;
|
|
@@ -1005,7 +1010,8 @@ const runTests = async ({
|
|
|
1005
1010
|
port,
|
|
1006
1011
|
test,
|
|
1007
1012
|
testSrc,
|
|
1008
|
-
timeout
|
|
1013
|
+
timeout,
|
|
1014
|
+
traceFocus
|
|
1009
1015
|
});
|
|
1010
1016
|
await onResult(result);
|
|
1011
1017
|
// @ts-ignore
|
|
@@ -1282,9 +1288,11 @@ const tearDownTests = async ({
|
|
|
1282
1288
|
* @param {string} testPath
|
|
1283
1289
|
* @param {string} cwd
|
|
1284
1290
|
* @param {boolean} headless
|
|
1285
|
-
* @param {number}
|
|
1291
|
+
* @param {number} timeout
|
|
1292
|
+
* @param {string} serverPath
|
|
1293
|
+
* @param {boolean} traceFocus
|
|
1286
1294
|
*/
|
|
1287
|
-
const runAllTests = async (extensionPath, testPath, cwd, headless, timeout, serverPath) => {
|
|
1295
|
+
const runAllTests = async (extensionPath, testPath, cwd, headless, timeout, serverPath, traceFocus) => {
|
|
1288
1296
|
string(extensionPath);
|
|
1289
1297
|
string(testPath);
|
|
1290
1298
|
string(cwd);
|
|
@@ -1323,7 +1331,8 @@ const runAllTests = async (extensionPath, testPath, cwd, headless, timeout, serv
|
|
|
1323
1331
|
port,
|
|
1324
1332
|
tests,
|
|
1325
1333
|
testSrc,
|
|
1326
|
-
timeout
|
|
1334
|
+
timeout,
|
|
1335
|
+
traceFocus
|
|
1327
1336
|
});
|
|
1328
1337
|
await tearDownTests({
|
|
1329
1338
|
child,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/test-with-playwright-worker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Worker package for test-with-playwright",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "dist/workerMain.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@playwright/test": "1.
|
|
15
|
+
"@playwright/test": "1.58.0"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=22"
|