@lvce-editor/test-with-playwright 22.12.1 → 22.13.1

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 +42 -13
  2. package/package.json +6 -3
package/dist/main.js CHANGED
@@ -135,6 +135,7 @@ Options:
135
135
  --test-path=<path> Path to the test files
136
136
  --timeout=<ms> Test timeout in milliseconds
137
137
  --trace-focus Log focus changes while tests run
138
+ --trace-renderer-worker Write renderer/worker command traces to renderer-worker-traces/
138
139
  --update-svg-screenshots Create or update expected SVG screenshots
139
140
  --electron-path=<path> Path to an existing Electron app executable
140
141
  --electron-version=<ver> Override the inferred Lvce release version
@@ -489,6 +490,7 @@ const parseCliArgs = argv => {
489
490
  if (parsed['trace-focus']) {
490
491
  result.traceFocus = true;
491
492
  }
493
+ setFlag(result, 'traceRendererWorker', parsed['trace-renderer-worker']);
492
494
  setFlag(result, 'updateSvgScreenshots', parsed['update-svg-screenshots']);
493
495
  return result;
494
496
  };
@@ -517,6 +519,7 @@ const defaultOptions = {
517
519
  runtime: 'browser',
518
520
  testPath: '',
519
521
  timeout: defaultTimeout,
522
+ traceRendererWorker: false,
520
523
  updateSvgScreenshots: false
521
524
  };
522
525
  const isBrowser = value => {
@@ -525,6 +528,11 @@ const isBrowser = value => {
525
528
  const isRuntime = value => {
526
529
  return value === 'browser' || value === 'electron';
527
530
  };
531
+ const validateRendererWorkerTrace = (traceRendererWorker, runtime) => {
532
+ if (traceRendererWorker && runtime === 'electron') {
533
+ throw new Error('[test-with-playwright] --trace-renderer-worker is only supported with --runtime=browser');
534
+ }
535
+ };
528
536
  const getOptions = ({
529
537
  argv,
530
538
  env
@@ -545,6 +553,7 @@ const getOptions = ({
545
553
  if (parsedArgs.reusePage && runtime === 'electron') {
546
554
  throw new Error('[test-with-playwright] --reuse-page is only supported with --runtime=browser');
547
555
  }
556
+ validateRendererWorkerTrace(parsedArgs.traceRendererWorker, runtime);
548
557
  if (parsedArgs.reusePage && parsedArgs.svgScreenshotDir) {
549
558
  throw new Error('[test-with-playwright] --svg-screenshot-dir is not supported with --reuse-page');
550
559
  }
@@ -610,7 +619,7 @@ const resolveServerEntryPoint = cwd => {
610
619
  };
611
620
  const getPossibleServerPaths = (cwd, serverPath) => {
612
621
  const resolvedServerEntryPoint = resolveServerEntryPoint(cwd);
613
- return [...(serverPath ? [resolve$1(cwd, serverPath)] : []), ...(resolvedServerEntryPoint ? [resolvedServerEntryPoint] : []), join(cwd, 'node_modules', '@lvce-editor', 'server', 'package.json'), join(cwd, '..', 'server', 'node_modules', '@lvce-editor', 'server', 'package.json'), join(cwd, '..', 'build', 'node_modules', '@lvce-editor', 'server', 'package.json')];
622
+ return [...(serverPath ? [resolve$1(cwd, serverPath)] : []), ...(resolvedServerEntryPoint ? [resolvedServerEntryPoint] : []), join(cwd, 'node_modules', '@lvce-editor', 'server', 'package.json'), join(cwd, '..', '..', 'node_modules', '@lvce-editor', 'server', 'package.json'), join(cwd, '..', 'server', 'node_modules', '@lvce-editor', 'server', 'package.json'), join(cwd, '..', 'build', 'node_modules', '@lvce-editor', 'server', 'package.json')];
614
623
  };
615
624
  const getElectronVersion = async ({
616
625
  cwd,
@@ -1523,7 +1532,10 @@ const constructError = (message, type, name) => {
1523
1532
  if (ErrorConstructor === Error) {
1524
1533
  const error = new Error(message);
1525
1534
  if (name && name !== 'VError') {
1526
- error.name = name;
1535
+ Object.defineProperty(error, 'name', {
1536
+ configurable: true,
1537
+ value: name
1538
+ });
1527
1539
  }
1528
1540
  return error;
1529
1541
  }
@@ -1554,31 +1566,45 @@ const getParentStack = error => {
1554
1566
  };
1555
1567
  const MethodNotFound = -32601;
1556
1568
  const Custom = -32001;
1569
+ const setStack = (error, stack) => {
1570
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
1571
+ if (descriptor) {
1572
+ if (!descriptor.configurable && !descriptor.writable) {
1573
+ return;
1574
+ }
1575
+ if (!descriptor.configurable && descriptor.writable) {
1576
+ error.stack = stack;
1577
+ return;
1578
+ }
1579
+ }
1580
+ Object.defineProperty(error, 'stack', {
1581
+ configurable: true,
1582
+ value: stack,
1583
+ writable: true
1584
+ });
1585
+ };
1557
1586
  const restoreExistingError = (error, currentStack) => {
1558
1587
  if (typeof error.stack === 'string') {
1559
- error.stack = error.stack + NewLine + currentStack;
1588
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
1560
1589
  }
1561
1590
  return error;
1562
1591
  };
1563
1592
  const restoreMethodNotFoundError = (error, currentStack) => {
1564
1593
  const restoredError = new JsonRpcError(error.message);
1565
1594
  const parentStack = getParentStack(error);
1566
- restoredError.stack = parentStack + NewLine + currentStack;
1595
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
1567
1596
  return restoredError;
1568
1597
  };
1569
1598
  const restoreStackFromData = (restoredError, error, currentStack) => {
1570
1599
  if (error.data.stack && error.data.type && error.message) {
1571
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1600
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
1572
1601
  return;
1573
1602
  }
1574
1603
  if (error.data.stack) {
1575
- restoredError.stack = error.data.stack;
1604
+ setStack(restoredError, error.data.stack);
1576
1605
  }
1577
1606
  };
1578
1607
  const applyDataProperties = (restoredError, error) => {
1579
- if (!error.data) {
1580
- return;
1581
- }
1582
1608
  restoreStackFromData(restoredError, error, getCurrentStack());
1583
1609
  if (error.data.codeFrame) {
1584
1610
  // @ts-ignore
@@ -1599,7 +1625,7 @@ const applyDirectProperties = (restoredError, error) => {
1599
1625
  const indexNewLine = getNewLineIndex(lowerStack);
1600
1626
  const parentStack = getParentStack(error);
1601
1627
  // @ts-ignore
1602
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1628
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
1603
1629
  }
1604
1630
  if (error.codeFrame) {
1605
1631
  // @ts-ignore
@@ -1963,7 +1989,8 @@ const runAllTests = async ({
1963
1989
  testPath,
1964
1990
  testWorkerUri,
1965
1991
  timeout,
1966
- traceFocus
1992
+ traceFocus,
1993
+ traceRendererWorker
1967
1994
  }) => {
1968
1995
  // TODO use `using` once supported
1969
1996
  const path = fileURLToPath(testWorkerUri);
@@ -1973,7 +2000,7 @@ const runAllTests = async ({
1973
2000
  path,
1974
2001
  stdio: 'inherit'
1975
2002
  });
1976
- await rpc.invoke(RunAllTests, onlyExtension, testPath, cwd, browser, headless, timeout, runtimeOptions, traceFocus, filter, reusePage, svgScreenshotOptions, coverage);
2003
+ await rpc.invoke(RunAllTests, onlyExtension, testPath, cwd, browser, headless, timeout, runtimeOptions, traceFocus, filter, reusePage, svgScreenshotOptions, coverage, traceRendererWorker);
1977
2004
  await rpc.dispose();
1978
2005
  };
1979
2006
 
@@ -2007,6 +2034,7 @@ const handleCliArgs = async ({
2007
2034
  testPath,
2008
2035
  timeout,
2009
2036
  traceFocus,
2037
+ traceRendererWorker,
2010
2038
  updateSvgScreenshots
2011
2039
  } = options;
2012
2040
  if (help) {
@@ -2060,7 +2088,8 @@ const handleCliArgs = async ({
2060
2088
  testPath,
2061
2089
  testWorkerUri,
2062
2090
  timeout,
2063
- traceFocus
2091
+ traceFocus,
2092
+ traceRendererWorker
2064
2093
  });
2065
2094
  };
2066
2095
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright",
3
- "version": "22.12.1",
3
+ "version": "22.13.1",
4
4
  "description": "CLI tool for running Playwright tests",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,8 +12,11 @@
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.12.1",
16
- "@lvce-editor/test-worker": "^17.7.1"
15
+ "@lvce-editor/test-with-playwright-worker": "22.13.1",
16
+ "@lvce-editor/test-worker": "^17.8.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/minimist": "^1.2.5"
17
20
  },
18
21
  "engines": {
19
22
  "node": ">=24"