@lvce-editor/test-with-playwright 20.2.0 → 22.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/README.md +20 -0
- package/dist/main.js +13 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ test('sample.hello-world', async () => {
|
|
|
33
33
|
- `--server-path`: explicit server entry point
|
|
34
34
|
- `--filter`: run only matching tests
|
|
35
35
|
- `--headless`: run Playwright in headless mode
|
|
36
|
+
- `--reuse-page`: run browser tests through `/tests/_all.html` on one page
|
|
36
37
|
- `--browser`: browser engine to launch: `chromium`, `firefox`, or `webkit`
|
|
37
38
|
- `--trace-focus`: add `traceFocus=true` to test URLs
|
|
38
39
|
- `--electron-path`: path to an existing Electron app executable
|
|
@@ -44,9 +45,28 @@ test('sample.hello-world', async () => {
|
|
|
44
45
|
## Runtime Notes
|
|
45
46
|
|
|
46
47
|
- `browser` keeps the server-backed HTML test execution flow.
|
|
48
|
+
- `--reuse-page` is browser-only. It loads `/tests/_all.html` once and reads JSON results from a hidden `.TestResults` element.
|
|
47
49
|
- `electron` downloads or reuses a Lvce Electron app, launches it with Playwright, and runs each test module against the first window.
|
|
48
50
|
- `--electron-path` skips downloading and is useful for custom local builds.
|
|
49
51
|
|
|
52
|
+
## Reuse Page Results
|
|
53
|
+
|
|
54
|
+
When `--reuse-page` is enabled, `/tests/_all.html` should run the tests and write a JSON array into `.TestResults`:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
[
|
|
58
|
+
{
|
|
59
|
+
"name": "sample.hello-world.js",
|
|
60
|
+
"status": "pass",
|
|
61
|
+
"error": "",
|
|
62
|
+
"start": 0,
|
|
63
|
+
"end": 12.5
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`status` must be `pass`, `skip`, or `fail`. `error` is optional and defaults to an empty string.
|
|
69
|
+
|
|
50
70
|
## Environment Variables
|
|
51
71
|
|
|
52
72
|
- `ONLY_EXTENSION`
|
package/dist/main.js
CHANGED
|
@@ -124,6 +124,7 @@ Options:
|
|
|
124
124
|
--runtime=<runtime> Runtime to run tests in: browser or electron
|
|
125
125
|
--filter=<pattern> Only run tests matching the filter
|
|
126
126
|
--headless Run the browser in headless mode
|
|
127
|
+
--reuse-page Run browser tests through /tests/_all.html on one page
|
|
127
128
|
--only-extension=<path> Path to the extension under test
|
|
128
129
|
--server-path=<path> Path to the editor server entrypoint
|
|
129
130
|
--test-path=<path> Path to the test files
|
|
@@ -416,6 +417,9 @@ const parseCliArgs = argv => {
|
|
|
416
417
|
if (parsed['only-extension']) {
|
|
417
418
|
result.onlyExtension = String(parsed['only-extension']);
|
|
418
419
|
}
|
|
420
|
+
if (parsed['reuse-page']) {
|
|
421
|
+
result.reusePage = true;
|
|
422
|
+
}
|
|
419
423
|
if (parsed['test-path']) {
|
|
420
424
|
result.testPath = String(parsed['test-path']);
|
|
421
425
|
}
|
|
@@ -462,6 +466,7 @@ const defaultOptions = {
|
|
|
462
466
|
extensionPath: '',
|
|
463
467
|
headless: false,
|
|
464
468
|
help: false,
|
|
469
|
+
reusePage: false,
|
|
465
470
|
runtime: 'browser',
|
|
466
471
|
testPath: ''
|
|
467
472
|
};
|
|
@@ -485,6 +490,9 @@ const getOptions = ({
|
|
|
485
490
|
}
|
|
486
491
|
const browser = parsedArgs.browser ?? defaultOptions.browser;
|
|
487
492
|
const runtime = parsedArgs.runtime ?? defaultOptions.runtime;
|
|
493
|
+
if (parsedArgs.reusePage && runtime === 'electron') {
|
|
494
|
+
throw new Error('[test-with-playwright] --reuse-page is only supported with --runtime=browser');
|
|
495
|
+
}
|
|
488
496
|
return {
|
|
489
497
|
...defaultOptions,
|
|
490
498
|
...parsedEnv,
|
|
@@ -1789,6 +1797,7 @@ const runAllTests = async ({
|
|
|
1789
1797
|
filter,
|
|
1790
1798
|
headless,
|
|
1791
1799
|
onlyExtension,
|
|
1800
|
+
reusePage,
|
|
1792
1801
|
runtimeOptions,
|
|
1793
1802
|
testPath,
|
|
1794
1803
|
testWorkerUri,
|
|
@@ -1798,12 +1807,12 @@ const runAllTests = async ({
|
|
|
1798
1807
|
// TODO use `using` once supported
|
|
1799
1808
|
const path = fileURLToPath(testWorkerUri);
|
|
1800
1809
|
const rpc = await create({
|
|
1801
|
-
argv: [],
|
|
1810
|
+
argv: [`--browser=${browser}`],
|
|
1802
1811
|
commandMap,
|
|
1803
1812
|
path,
|
|
1804
1813
|
stdio: 'inherit'
|
|
1805
1814
|
});
|
|
1806
|
-
await rpc.invoke(RunAllTests, onlyExtension, testPath, cwd, browser, headless, timeout, runtimeOptions, traceFocus, filter);
|
|
1815
|
+
await rpc.invoke(RunAllTests, onlyExtension, testPath, cwd, browser, headless, timeout, runtimeOptions, traceFocus, filter, reusePage);
|
|
1807
1816
|
await rpc.dispose();
|
|
1808
1817
|
};
|
|
1809
1818
|
|
|
@@ -1828,6 +1837,7 @@ const handleCliArgs = async ({
|
|
|
1828
1837
|
headless,
|
|
1829
1838
|
help,
|
|
1830
1839
|
onlyExtension,
|
|
1840
|
+
reusePage,
|
|
1831
1841
|
runtime,
|
|
1832
1842
|
serverPath,
|
|
1833
1843
|
testPath,
|
|
@@ -1869,6 +1879,7 @@ const handleCliArgs = async ({
|
|
|
1869
1879
|
headless,
|
|
1870
1880
|
// @ts-ignore
|
|
1871
1881
|
onlyExtension,
|
|
1882
|
+
reusePage,
|
|
1872
1883
|
runtimeOptions,
|
|
1873
1884
|
testPath,
|
|
1874
1885
|
testWorkerUri,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/test-with-playwright",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.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": "
|
|
16
|
-
"@lvce-editor/test-worker": "^16.
|
|
15
|
+
"@lvce-editor/test-with-playwright-worker": "22.0.0",
|
|
16
|
+
"@lvce-editor/test-worker": "^16.5.0"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=24"
|