@lvce-editor/test-with-playwright 22.5.0 → 22.6.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.
Files changed (2) hide show
  1. package/dist/main.js +76 -46
  2. package/package.json +3 -3
package/dist/main.js CHANGED
@@ -1035,7 +1035,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
1035
1035
  for (const property of Object.values(value)) {
1036
1036
  walkValue(property, transferrables, isTransferrable);
1037
1037
  }
1038
- return;
1039
1038
  }
1040
1039
  };
1041
1040
  const getTransferrables = value => {
@@ -1189,7 +1188,14 @@ class IpcError extends VError {
1189
1188
  const cause = new Error(message);
1190
1189
  // @ts-ignore
1191
1190
  cause.code = code;
1192
- cause.stack = stack;
1191
+ if (stack) {
1192
+ Object.defineProperty(cause, 'stack', {
1193
+ configurable: true,
1194
+ enumerable: false,
1195
+ value: stack,
1196
+ writable: true
1197
+ });
1198
+ }
1193
1199
  super(cause, betterMessage);
1194
1200
  } else {
1195
1201
  super(betterMessage);
@@ -1426,8 +1432,10 @@ const getCurrentStack = () => {
1426
1432
  const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
1427
1433
  return currentStack;
1428
1434
  };
1429
- const getNewLineIndex = (string, startIndex = undefined) => {
1430
- return string.indexOf(NewLine, startIndex);
1435
+ const getNewLineIndex = (string, startIndex) => {
1436
+ {
1437
+ return string.indexOf(NewLine);
1438
+ }
1431
1439
  };
1432
1440
  const getParentStack = error => {
1433
1441
  let parentStack = error.stack || error.data || error.message || '';
@@ -1438,55 +1446,77 @@ const getParentStack = error => {
1438
1446
  };
1439
1447
  const MethodNotFound = -32601;
1440
1448
  const Custom = -32001;
1449
+ const restoreExistingError = (error, currentStack) => {
1450
+ if (typeof error.stack === 'string') {
1451
+ error.stack = error.stack + NewLine + currentStack;
1452
+ }
1453
+ return error;
1454
+ };
1455
+ const restoreMethodNotFoundError = (error, currentStack) => {
1456
+ const restoredError = new JsonRpcError(error.message);
1457
+ const parentStack = getParentStack(error);
1458
+ restoredError.stack = parentStack + NewLine + currentStack;
1459
+ return restoredError;
1460
+ };
1461
+ const restoreStackFromData = (restoredError, error, currentStack) => {
1462
+ if (error.data.stack && error.data.type && error.message) {
1463
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1464
+ return;
1465
+ }
1466
+ if (error.data.stack) {
1467
+ restoredError.stack = error.data.stack;
1468
+ }
1469
+ };
1470
+ const applyDataProperties = (restoredError, error) => {
1471
+ if (!error.data) {
1472
+ return;
1473
+ }
1474
+ restoreStackFromData(restoredError, error, getCurrentStack());
1475
+ if (error.data.codeFrame) {
1476
+ // @ts-ignore
1477
+ restoredError.codeFrame = error.data.codeFrame;
1478
+ }
1479
+ if (error.data.code) {
1480
+ // @ts-ignore
1481
+ restoredError.code = error.data.code;
1482
+ }
1483
+ if (error.data.type) {
1484
+ // @ts-ignore
1485
+ restoredError.name = error.data.type;
1486
+ }
1487
+ };
1488
+ const applyDirectProperties = (restoredError, error) => {
1489
+ if (error.stack) {
1490
+ const lowerStack = restoredError.stack || '';
1491
+ const indexNewLine = getNewLineIndex(lowerStack);
1492
+ const parentStack = getParentStack(error);
1493
+ // @ts-ignore
1494
+ restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1495
+ }
1496
+ if (error.codeFrame) {
1497
+ // @ts-ignore
1498
+ restoredError.codeFrame = error.codeFrame;
1499
+ }
1500
+ };
1501
+ const restoreMessageError = (error, _currentStack) => {
1502
+ const restoredError = constructError(error.message, error.type, error.name);
1503
+ if (error.data) {
1504
+ applyDataProperties(restoredError, error);
1505
+ } else {
1506
+ applyDirectProperties(restoredError, error);
1507
+ }
1508
+ return restoredError;
1509
+ };
1441
1510
  const restoreJsonRpcError = error => {
1442
1511
  const currentStack = getCurrentStack();
1443
1512
  if (error && error instanceof Error) {
1444
- if (typeof error.stack === 'string') {
1445
- error.stack = error.stack + NewLine + currentStack;
1446
- }
1447
- return error;
1513
+ return restoreExistingError(error, currentStack);
1448
1514
  }
1449
1515
  if (error && error.code && error.code === MethodNotFound) {
1450
- const restoredError = new JsonRpcError(error.message);
1451
- const parentStack = getParentStack(error);
1452
- restoredError.stack = parentStack + NewLine + currentStack;
1453
- return restoredError;
1516
+ return restoreMethodNotFoundError(error, currentStack);
1454
1517
  }
1455
1518
  if (error && error.message) {
1456
- const restoredError = constructError(error.message, error.type, error.name);
1457
- if (error.data) {
1458
- if (error.data.stack && error.data.type && error.message) {
1459
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1460
- } else if (error.data.stack) {
1461
- restoredError.stack = error.data.stack;
1462
- }
1463
- if (error.data.codeFrame) {
1464
- // @ts-ignore
1465
- restoredError.codeFrame = error.data.codeFrame;
1466
- }
1467
- if (error.data.code) {
1468
- // @ts-ignore
1469
- restoredError.code = error.data.code;
1470
- }
1471
- if (error.data.type) {
1472
- // @ts-ignore
1473
- restoredError.name = error.data.type;
1474
- }
1475
- } else {
1476
- if (error.stack) {
1477
- const lowerStack = restoredError.stack || '';
1478
- // @ts-ignore
1479
- const indexNewLine = getNewLineIndex(lowerStack);
1480
- const parentStack = getParentStack(error);
1481
- // @ts-ignore
1482
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1483
- }
1484
- if (error.codeFrame) {
1485
- // @ts-ignore
1486
- restoredError.codeFrame = error.codeFrame;
1487
- }
1488
- }
1489
- return restoredError;
1519
+ return restoreMessageError(error);
1490
1520
  }
1491
1521
  if (typeof error === 'string') {
1492
1522
  return new Error(`JsonRpc Error: ${error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright",
3
- "version": "22.5.0",
3
+ "version": "22.6.0",
4
4
  "description": "CLI tool for running Playwright tests",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,8 +12,8 @@
12
12
  "main": "dist/main.js",
13
13
  "bin": "bin/test-with-playwright.js",
14
14
  "dependencies": {
15
- "@lvce-editor/test-with-playwright-worker": "22.5.0",
16
- "@lvce-editor/test-worker": "^17.0.2"
15
+ "@lvce-editor/test-with-playwright-worker": "22.6.0",
16
+ "@lvce-editor/test-worker": "^17.1.0"
17
17
  },
18
18
  "engines": {
19
19
  "node": ">=24"