@lvce-editor/test-with-playwright-worker 4.1.0 → 5.0.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.
- package/package.json +6 -7
- package/src/parts/Main/Main.js +6 -8
- package/src/parts/RpcId/RpcId.js +1 -0
- package/src/parts/RunAllTests/RunAllTests.js +8 -7
- package/src/parts/RunTests/RunTests.js +2 -2
- package/index.js +0 -6
- package/src/parts/HandleIpc/HandleIpc.js +0 -5
- package/src/parts/HandleMessage/HandleMessage.js +0 -29
- package/src/parts/IpcChild/IpcChild.js +0 -15
- package/src/parts/IpcChildModule/IpcChildModule.js +0 -25
- package/src/parts/IpcChildType/IpcChildType.js +0 -19
- package/src/parts/JsonRpc/JsonRpc.js +0 -1
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/test-with-playwright-worker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "src/workerMain.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -10,15 +10,14 @@
|
|
|
10
10
|
"directory": "packages/test-with-playwright-worker"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
|
-
"author": "",
|
|
13
|
+
"author": "Lvce Editor",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@lvce-editor/assert": "^1.4.0",
|
|
17
|
-
"@lvce-editor/
|
|
18
|
-
"@lvce-editor/
|
|
19
|
-
"@lvce-editor/json-rpc": "^7.0.0",
|
|
17
|
+
"@lvce-editor/rpc": "^4.18.0",
|
|
18
|
+
"@lvce-editor/rpc-registry": "^3.6.0",
|
|
20
19
|
"@lvce-editor/verror": "^1.7.0",
|
|
21
|
-
"@playwright/test": "
|
|
20
|
+
"@playwright/test": "1.55.0",
|
|
22
21
|
"get-port": "^7.1.0"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
package/src/parts/Main/Main.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NodeWorkerRpcClient } from '@lvce-editor/rpc'
|
|
2
2
|
import * as CommandMap from '../CommandMap/CommandMap.js'
|
|
3
|
-
import * as HandleIpc from '../HandleIpc/HandleIpc.js'
|
|
4
|
-
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
5
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
6
3
|
import * as Process from '../Process/Process.js'
|
|
7
4
|
import * as ProcessListeners from '../ProcessListeners/ProcessListeners.js'
|
|
5
|
+
import { set } from '@lvce-editor/rpc-registry'
|
|
6
|
+
import { Cli } from '../RpcId/RpcId.js'
|
|
8
7
|
|
|
9
8
|
const handleDisconnect = () => {
|
|
10
9
|
console.log('[test-worker] disconnected')
|
|
@@ -28,9 +27,8 @@ export const main = async () => {
|
|
|
28
27
|
Process.on('SIGINT', handleSigint)
|
|
29
28
|
Process.on('SIGTERM', handleSigTerm)
|
|
30
29
|
Process.on('uncaughtExceptionMonitor', ProcessListeners.handleUncaughtExceptionMonitor)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
method: IpcChildType.Auto(),
|
|
30
|
+
const rpc = await NodeWorkerRpcClient.create({
|
|
31
|
+
commandMap: CommandMap.commandMap,
|
|
34
32
|
})
|
|
35
|
-
|
|
33
|
+
set(Cli, rpc)
|
|
36
34
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const Cli = 6001
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
+
import { get } from '@lvce-editor/rpc-registry'
|
|
1
2
|
import { join } from 'path'
|
|
2
3
|
import * as Assert from '../Assert/Assert.js'
|
|
4
|
+
import * as CliCommandType from '../CliCommandType/CliCommandType.js'
|
|
3
5
|
import * as GetTests from '../GetTests/GetTests.js'
|
|
6
|
+
import { Cli } from '../RpcId/RpcId.js'
|
|
4
7
|
import * as RunTests from '../RunTests/RunTests.js'
|
|
5
8
|
import * as SetupTests from '../SetupTests/SetupTests.js'
|
|
6
9
|
import * as TearDownTests from '../TearDownTests/TearDownTests.js'
|
|
7
|
-
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
8
|
-
import * as CliCommandType from '../CliCommandType/CliCommandType.js'
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
* @param {any} ipc
|
|
12
12
|
* @param {string} extensionPath
|
|
13
13
|
* @param {string} testPath
|
|
14
14
|
* @param {string} cwd
|
|
15
15
|
* @param {boolean} headless
|
|
16
16
|
* @param {number} headless
|
|
17
17
|
*/
|
|
18
|
-
export const runAllTests = async (
|
|
18
|
+
export const runAllTests = async (extensionPath, testPath, cwd, headless, timeout) => {
|
|
19
19
|
Assert.string(extensionPath)
|
|
20
20
|
Assert.string(testPath)
|
|
21
21
|
Assert.string(cwd)
|
|
22
22
|
Assert.boolean(headless)
|
|
23
23
|
Assert.number(timeout)
|
|
24
|
+
const rpc = get(Cli)
|
|
24
25
|
const controller = new AbortController()
|
|
25
26
|
const signal = controller.signal
|
|
26
27
|
const { page, child, port } = await SetupTests.setupTests({
|
|
@@ -31,11 +32,11 @@ export const runAllTests = async (ipc, extensionPath, testPath, cwd, headless, t
|
|
|
31
32
|
})
|
|
32
33
|
const testSrc = join(testPath, 'src')
|
|
33
34
|
const tests = await GetTests.getTests(testSrc)
|
|
34
|
-
const onResult = (result) => {
|
|
35
|
-
|
|
35
|
+
const onResult = async (result) => {
|
|
36
|
+
await rpc.invoke(CliCommandType.HandleResult, result)
|
|
36
37
|
}
|
|
37
38
|
const onFinalResult = (finalResult) => {
|
|
38
|
-
|
|
39
|
+
rpc.invoke(CliCommandType.HandleFinalResult, finalResult)
|
|
39
40
|
}
|
|
40
41
|
await RunTests.runTests({ testSrc, tests, headless, port, page, timeout, onResult, onFinalResult })
|
|
41
42
|
await TearDownTests.tearDownTests({
|
|
@@ -18,7 +18,7 @@ export const runTests = async ({ testSrc, tests, headless, page, port, timeout,
|
|
|
18
18
|
port,
|
|
19
19
|
timeout,
|
|
20
20
|
})
|
|
21
|
-
onResult(result)
|
|
21
|
+
await onResult(result)
|
|
22
22
|
switch (result.status) {
|
|
23
23
|
case TestState.Fail:
|
|
24
24
|
failed++
|
|
@@ -34,7 +34,7 @@ export const runTests = async ({ testSrc, tests, headless, page, port, timeout,
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
const end = performance.now()
|
|
37
|
-
onFinalResult({
|
|
37
|
+
await onFinalResult({
|
|
38
38
|
passed,
|
|
39
39
|
failed,
|
|
40
40
|
skipped,
|
package/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as Command from '../Command/Command.js'
|
|
2
|
-
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
3
|
-
|
|
4
|
-
const prepare = (error) => {
|
|
5
|
-
return error
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const requiresSocket = (method) => {
|
|
9
|
-
if (method === 'RunAllTests') {
|
|
10
|
-
return true
|
|
11
|
-
}
|
|
12
|
-
return false
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const logError = (error) => {
|
|
16
|
-
console.error(error)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const handleMessage = (event) => {
|
|
20
|
-
return JsonRpc.handleJsonRpcMessage(
|
|
21
|
-
event.target,
|
|
22
|
-
event.data,
|
|
23
|
-
Command.execute,
|
|
24
|
-
JsonRpc.resolve,
|
|
25
|
-
prepare,
|
|
26
|
-
logError,
|
|
27
|
-
requiresSocket,
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as IpcChildModule from '../IpcChildModule/IpcChildModule.js'
|
|
2
|
-
|
|
3
|
-
export const listen = async ({ method, ...params }) => {
|
|
4
|
-
const module = await IpcChildModule.getModule(method)
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const rawIpc = await module.listen(params)
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
if (module.signal) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
module.signal(rawIpc)
|
|
11
|
-
}
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
const ipc = module.wrap(rawIpc)
|
|
14
|
-
return ipc
|
|
15
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IpcChildWithElectronMessagePort,
|
|
3
|
-
IpcChildWithElectronUtilityProcess,
|
|
4
|
-
IpcChildWithNodeForkedProcess,
|
|
5
|
-
IpcChildWithNodeWorker,
|
|
6
|
-
IpcChildWithWebSocket,
|
|
7
|
-
} from '@lvce-editor/ipc'
|
|
8
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
9
|
-
|
|
10
|
-
export const getModule = (method) => {
|
|
11
|
-
switch (method) {
|
|
12
|
-
case IpcChildType.NodeForkedProcess:
|
|
13
|
-
return IpcChildWithNodeForkedProcess
|
|
14
|
-
case IpcChildType.NodeWorker:
|
|
15
|
-
return IpcChildWithNodeWorker
|
|
16
|
-
case IpcChildType.ElectronUtilityProcess:
|
|
17
|
-
return IpcChildWithElectronUtilityProcess
|
|
18
|
-
case IpcChildType.ElectronMessagePort:
|
|
19
|
-
return IpcChildWithElectronMessagePort
|
|
20
|
-
case IpcChildType.WebSocket:
|
|
21
|
-
return IpcChildWithWebSocket
|
|
22
|
-
default:
|
|
23
|
-
throw new Error('unexpected ipc type')
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const NodeWorker = 1
|
|
2
|
-
export const NodeForkedProcess = 2
|
|
3
|
-
export const ElectronUtilityProcess = 3
|
|
4
|
-
export const ElectronMessagePort = 4
|
|
5
|
-
export const WebSocket = 6
|
|
6
|
-
|
|
7
|
-
export const Auto = () => {
|
|
8
|
-
const { argv } = process
|
|
9
|
-
if (argv.includes('--ipc-type=node-worker')) {
|
|
10
|
-
return NodeWorker
|
|
11
|
-
}
|
|
12
|
-
if (argv.includes('--ipc-type=node-forked-process')) {
|
|
13
|
-
return NodeForkedProcess
|
|
14
|
-
}
|
|
15
|
-
if (argv.includes('--ipc-type=electron-utility-process')) {
|
|
16
|
-
return ElectronUtilityProcess
|
|
17
|
-
}
|
|
18
|
-
throw new Error(`[shared-process] unknown ipc type`)
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@lvce-editor/json-rpc'
|