@lvce-editor/test-with-playwright 4.0.0 → 5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "",
5
5
  "main": "src/main.js",
6
6
  "type": "module",
@@ -10,17 +10,15 @@
10
10
  "url": "git@github.com:lvce-editor/test-with-playwright.git"
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/command": "^2.0.0",
18
- "@lvce-editor/ipc": "^14.5.0",
19
- "@lvce-editor/json-rpc": "^7.0.0",
17
+ "@lvce-editor/rpc": "^4.18.0",
20
18
  "@lvce-editor/verror": "^1.7.0",
21
19
  "minimist": "^1.2.8",
22
- "@lvce-editor/test-with-playwright-worker": "4.0.0",
23
- "@lvce-editor/test-worker": "^5.0.0"
20
+ "@lvce-editor/test-with-playwright-worker": "5.0.0",
21
+ "@lvce-editor/test-worker": "^5.4.0"
24
22
  },
25
23
  "devDependencies": {
26
24
  "@types/jest": "^30.0.0",
@@ -1,5 +1,3 @@
1
- import { testWorkerPath } from '@lvce-editor/test-with-playwright-worker'
2
-
3
1
  export const getTestWorkerPath = () => {
4
- return testWorkerPath
2
+ return import.meta.resolve('@lvce-editor/test-with-playwright-worker')
5
3
  }
@@ -1,17 +1,20 @@
1
1
  import * as GetOptions from '../GetOptions/GetOptions.js'
2
2
  import * as RunAllTests from '../RunAllTests/RunAllTests.js'
3
+ import * as GetTestWorkerPath from '../GetTestWorkerPath/GetTestWorkerPath.js'
3
4
 
4
5
  /**
5
6
  *
6
- * @param {{argv:string[], env:any}} param0
7
+ * @param {{argv:string[], env:any, commandMap:any}} param0
7
8
  */
8
- export const handleCliArgs = async ({ argv, env }) => {
9
+ export const handleCliArgs = async ({ argv, env, commandMap }) => {
9
10
  const cwd = process.cwd()
10
11
  const options = GetOptions.getOptions({ argv, env })
11
12
  const onlyExtension = options.onlyExtension
12
13
  const testPath = options.testPath
13
14
  const headless = options.headless
14
15
  const timeout = 30_000
16
+ const testWorkerPath = GetTestWorkerPath.getTestWorkerPath()
17
+
15
18
  // TODO
16
19
  // console.log({ argv, env })
17
20
  await RunAllTests.runAllTests({
@@ -20,5 +23,7 @@ export const handleCliArgs = async ({ argv, env }) => {
20
23
  cwd,
21
24
  headless,
22
25
  timeout,
26
+ commandMap,
27
+ testWorkerPath,
23
28
  })
24
29
  }
@@ -1,11 +1,9 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as CommandMap from '../CommandMap/CommandMap.js'
3
2
  import * as HandleCliArgs from '../HandleCliArgs/HandleCliArgs.js'
4
3
  import * as Process from '../Process/Process.js'
5
4
  import * as ProcessListeners from '../ProcessListeners/ProcessListeners.js'
6
5
 
7
- export const main = () => {
6
+ export const main = async () => {
8
7
  Process.on('uncaughtExceptionMonitor', ProcessListeners.handleUncaughtExceptionMonitor)
9
- Command.register(CommandMap.commandMap)
10
- HandleCliArgs.handleCliArgs({ argv: Process.argv, env: Process.env })
8
+ await HandleCliArgs.handleCliArgs({ argv: Process.argv, env: Process.env, commandMap: CommandMap.commandMap })
11
9
  }
@@ -1,22 +1,17 @@
1
- import * as GetTestWorkerPath from '../GetTestWorkerPath/GetTestWorkerPath.js'
2
- import * as HandleIpc from '../HandleIpc/HandleIpc.js'
3
- import * as IpcParent from '../IpcParent/IpcParent.js'
4
- import * as IpcParentType from '../IpcParentType/IpcParentType.js'
5
- import * as JsonRpc from '../JsonRpc/JsonRpc.js'
1
+ import { NodeWorkerRpcParent } from '@lvce-editor/rpc'
6
2
  import * as TestWorkerCommandType from '../TestWorkerCommandType/TestWorkerCommandType.js'
7
3
 
8
4
  /**
9
5
  *
10
- * @param {{onlyExtension:string, testPath:string, cwd:string, headless:boolean, timeout:number}} param0
6
+ * @param {{onlyExtension:string, testPath:string, cwd:string, headless:boolean, timeout:number, commandMap:any, testWorkerPath:string}} param0
11
7
  */
12
- export const runAllTests = async ({ onlyExtension, testPath, cwd, headless, timeout }) => {
13
- const path = GetTestWorkerPath.getTestWorkerPath()
14
- const ipc = await IpcParent.create({
15
- method: IpcParentType.NodeWorker,
16
- path,
8
+ export const runAllTests = async ({ onlyExtension, testPath, cwd, headless, timeout, commandMap, testWorkerPath }) => {
9
+ // TODO use `using` once supported
10
+ const rpc = await NodeWorkerRpcParent.create({
11
+ path: testWorkerPath,
17
12
  argv: [],
13
+ commandMap,
18
14
  })
19
- HandleIpc.handleIpc(ipc)
20
- await JsonRpc.invoke(ipc, TestWorkerCommandType.RunAllTests, onlyExtension, testPath, cwd, headless, timeout)
21
- ipc.dispose()
15
+ await rpc.invoke(TestWorkerCommandType.RunAllTests, onlyExtension, testPath, cwd, headless, timeout)
16
+ await rpc.dispose()
22
17
  }
@@ -1 +0,0 @@
1
- export * from '@lvce-editor/command'
@@ -1,5 +0,0 @@
1
- import * as HandleMessage from '../HandleMessage/HandleMessage.js'
2
-
3
- export const handleIpc = (ipc) => {
4
- ipc.addEventListener('message', HandleMessage.handleMessage)
5
- }
@@ -1,26 +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
- return false
10
- }
11
-
12
- const logError = (error) => {
13
- console.error(error)
14
- }
15
-
16
- export const handleMessage = (event) => {
17
- return JsonRpc.handleJsonRpcMessage(
18
- event.target,
19
- event.data,
20
- Command.execute,
21
- JsonRpc.resolve,
22
- prepare,
23
- logError,
24
- requiresSocket,
25
- )
26
- }
@@ -1,9 +0,0 @@
1
- import * as IpcParentModule from '../IpcParentModule/IpcParentModule.js'
2
-
3
- export const create = async ({ method, ...options }) => {
4
- const module = IpcParentModule.getModule(method)
5
- // @ts-ignore
6
- const rawIpc = await module.create(options)
7
- const ipc = module.wrap(rawIpc)
8
- return ipc
9
- }
@@ -1,11 +0,0 @@
1
- import * as IpcParentType from '../IpcParentType/IpcParentType.js'
2
- import { IpcParentWithNodeWorker } from '@lvce-editor/ipc'
3
-
4
- export const getModule = (method) => {
5
- switch (method) {
6
- case IpcParentType.NodeWorker:
7
- return IpcParentWithNodeWorker
8
- default:
9
- throw new Error('unexpected ipc type')
10
- }
11
- }
@@ -1,2 +0,0 @@
1
- export const NodeWorker = 1
2
- export const NodeForkedProcess = 2
@@ -1 +0,0 @@
1
- export * from '@lvce-editor/json-rpc'