@lvce-editor/test-with-playwright 22.0.0 → 22.2.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/README.md CHANGED
@@ -34,6 +34,7 @@ test('sample.hello-world', async () => {
34
34
  - `--filter`: run only matching tests
35
35
  - `--headless`: run Playwright in headless mode
36
36
  - `--reuse-page`: run browser tests through `/tests/_all.html` on one page
37
+ - `--timeout`: test timeout in milliseconds, defaults to `30000` or `600000` with `--reuse-page`
37
38
  - `--browser`: browser engine to launch: `chromium`, `firefox`, or `webkit`
38
39
  - `--trace-focus`: add `traceFocus=true` to test URLs
39
40
  - `--electron-path`: path to an existing Electron app executable
package/dist/main.js CHANGED
@@ -128,6 +128,7 @@ Options:
128
128
  --only-extension=<path> Path to the extension under test
129
129
  --server-path=<path> Path to the editor server entrypoint
130
130
  --test-path=<path> Path to the test files
131
+ --timeout=<ms> Test timeout in milliseconds
131
132
  --trace-focus Log focus changes while tests run
132
133
  --electron-path=<path> Path to an existing Electron app executable
133
134
  --electron-version=<ver> Lvce release version to download, for example v0.84.0
@@ -396,6 +397,18 @@ const toStringArray = value => {
396
397
  }
397
398
  return [toCliString(value)];
398
399
  };
400
+ const toPositiveNumber = (value, name) => {
401
+ const number = Number(toCliString(value));
402
+ if (!Number.isFinite(number) || number <= 0) {
403
+ throw new TypeError(`expected ${name} to be a positive number`);
404
+ }
405
+ return number;
406
+ };
407
+ const setOptionalPositiveNumber = (result, key, value, name) => {
408
+ if (value !== undefined) {
409
+ result[key] = toPositiveNumber(value, name);
410
+ }
411
+ };
399
412
  const parseCliArgs = argv => {
400
413
  const parsed = parseArgv(argv);
401
414
  const result = Object.create(null);
@@ -423,6 +436,7 @@ const parseCliArgs = argv => {
423
436
  if (parsed['test-path']) {
424
437
  result.testPath = String(parsed['test-path']);
425
438
  }
439
+ setOptionalPositiveNumber(result, 'timeout', parsed.timeout, '--timeout');
426
440
  if (parsed['server-path']) {
427
441
  result.serverPath = String(parsed['server-path']);
428
442
  }
@@ -461,6 +475,8 @@ const parseEnv = env => {
461
475
  };
462
476
 
463
477
  const browsers = ['chromium', 'firefox', 'webkit'];
478
+ const defaultTimeout = 30_000;
479
+ const reusePageDefaultTimeout = 600_000;
464
480
  const defaultOptions = {
465
481
  browser: 'chromium',
466
482
  extensionPath: '',
@@ -468,7 +484,8 @@ const defaultOptions = {
468
484
  help: false,
469
485
  reusePage: false,
470
486
  runtime: 'browser',
471
- testPath: ''
487
+ testPath: '',
488
+ timeout: defaultTimeout
472
489
  };
473
490
  const isBrowser = value => {
474
491
  return browsers.includes(value);
@@ -493,12 +510,16 @@ const getOptions = ({
493
510
  if (parsedArgs.reusePage && runtime === 'electron') {
494
511
  throw new Error('[test-with-playwright] --reuse-page is only supported with --runtime=browser');
495
512
  }
513
+ const reusePage = parsedArgs.reusePage ?? defaultOptions.reusePage;
514
+ const timeout = parsedArgs.timeout ?? (reusePage ? reusePageDefaultTimeout : defaultTimeout);
496
515
  return {
497
516
  ...defaultOptions,
498
517
  ...parsedEnv,
499
518
  ...parsedArgs,
500
519
  browser,
501
- runtime
520
+ reusePage,
521
+ runtime,
522
+ timeout
502
523
  };
503
524
  };
504
525
 
@@ -1841,13 +1862,13 @@ const handleCliArgs = async ({
1841
1862
  runtime,
1842
1863
  serverPath,
1843
1864
  testPath,
1865
+ timeout,
1844
1866
  traceFocus
1845
1867
  } = options;
1846
1868
  if (help) {
1847
1869
  console.info(getHelpMessage());
1848
1870
  return;
1849
1871
  }
1850
- const timeout = 30_000;
1851
1872
  const testWorkerUri = getTestWorkerUrl();
1852
1873
  const runtimeOptions = await getRuntimeOptions({
1853
1874
  cwd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright",
3
- "version": "22.0.0",
3
+ "version": "22.2.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.0.0",
16
- "@lvce-editor/test-worker": "^16.5.0"
15
+ "@lvce-editor/test-with-playwright-worker": "22.2.0",
16
+ "@lvce-editor/test-worker": "^17.0.0"
17
17
  },
18
18
  "engines": {
19
19
  "node": ">=24"