@lvce-editor/test-with-playwright 1.3.0 → 1.5.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 +3 -2
- package/src/parts/Assert/Assert.js +1 -59
- package/src/parts/GetTests/GetTests.js +0 -1
- package/src/parts/IpcParentModule/IpcParentModule.js +0 -2
- package/src/parts/AssertionError/AssertionError.js +0 -6
- package/src/parts/IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js +0 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/test-with-playwright",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/parts/RunAllTests/RunAllTests.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"@lvce-editor/assert": "^1.3.0",
|
|
16
17
|
"minimist": "^1.2.8",
|
|
17
|
-
"@lvce-editor/test-with-playwright-worker": "1.
|
|
18
|
+
"@lvce-editor/test-with-playwright-worker": "1.5.0"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@types/jest": "^29.5.12",
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const getType = (value) => {
|
|
4
|
-
switch (typeof value) {
|
|
5
|
-
case 'number':
|
|
6
|
-
return 'number'
|
|
7
|
-
case 'function':
|
|
8
|
-
return 'function'
|
|
9
|
-
case 'string':
|
|
10
|
-
return 'string'
|
|
11
|
-
case 'object':
|
|
12
|
-
if (value === null) {
|
|
13
|
-
return 'null'
|
|
14
|
-
}
|
|
15
|
-
if (Array.isArray(value)) {
|
|
16
|
-
return 'array'
|
|
17
|
-
}
|
|
18
|
-
return 'object'
|
|
19
|
-
case 'boolean':
|
|
20
|
-
return 'boolean'
|
|
21
|
-
default:
|
|
22
|
-
return 'unknown'
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const object = (value) => {
|
|
27
|
-
const type = getType(value)
|
|
28
|
-
if (type !== 'object') {
|
|
29
|
-
throw new AssertionError('expected value to be of type object')
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const number = (value) => {
|
|
34
|
-
const type = getType(value)
|
|
35
|
-
if (type !== 'number') {
|
|
36
|
-
throw new AssertionError('expected value to be of type number')
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const array = (value) => {
|
|
41
|
-
const type = getType(value)
|
|
42
|
-
if (type !== 'array') {
|
|
43
|
-
throw new AssertionError('expected value to be of type array')
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const string = (value) => {
|
|
48
|
-
const type = getType(value)
|
|
49
|
-
if (type !== 'string') {
|
|
50
|
-
throw new AssertionError('expected value to be of type string')
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const boolean = (value) => {
|
|
55
|
-
const type = getType(value)
|
|
56
|
-
if (type !== 'boolean') {
|
|
57
|
-
throw new AssertionError('expected value to be of type boolean')
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
export * from '@lvce-editor/assert'
|
|
@@ -4,8 +4,6 @@ export const getModule = (method) => {
|
|
|
4
4
|
switch (method) {
|
|
5
5
|
case IpcParentType.NodeWorker:
|
|
6
6
|
return import('../IpcParentWithNodeWorker/IpcParentWithNodeWorker.js')
|
|
7
|
-
case IpcParentType.NodeForkedProcess:
|
|
8
|
-
return import('../IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js')
|
|
9
7
|
default:
|
|
10
8
|
throw new Error('unexpected ipc type')
|
|
11
9
|
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import { fork } from 'node:child_process'
|
|
3
|
-
import * as GetFirstNodeChildProcessEvent from '../GetFirstNodeChildProcessEvent/GetFirstNodeChildProcessEvent.js'
|
|
4
|
-
import * as FirstNodeWorkerEventType from '../FirstNodeWorkerEventType/FirstNodeWorkerEventType.js'
|
|
5
|
-
import { ChildProcessError } from '../ChildProcessError/ChildProcessError.js'
|
|
6
|
-
import { VError } from '../VError/VError.js'
|
|
7
|
-
|
|
8
|
-
export const create = async ({ path, argv = [], env, execArgv = [], stdio = 'inherit', name = 'child process' }) => {
|
|
9
|
-
try {
|
|
10
|
-
Assert.string(path)
|
|
11
|
-
const actualArgv = ['--ipc-type=node-forked-process', ...argv]
|
|
12
|
-
const childProcess = fork(path, actualArgv, {
|
|
13
|
-
env,
|
|
14
|
-
execArgv,
|
|
15
|
-
stdio: 'pipe',
|
|
16
|
-
})
|
|
17
|
-
const { type, event, stdout, stderr } = await GetFirstNodeChildProcessEvent.getFirstNodeChildProcessEvent(childProcess)
|
|
18
|
-
if (type === FirstNodeWorkerEventType.Exit) {
|
|
19
|
-
throw new ChildProcessError(stderr)
|
|
20
|
-
}
|
|
21
|
-
if (type === FirstNodeWorkerEventType.Error) {
|
|
22
|
-
throw new Error(`child process had an error ${event}`)
|
|
23
|
-
}
|
|
24
|
-
if (stdio === 'inherit' && childProcess.stdout && childProcess.stderr) {
|
|
25
|
-
childProcess.stdout.pipe(process.stdout)
|
|
26
|
-
childProcess.stderr.pipe(process.stderr)
|
|
27
|
-
}
|
|
28
|
-
return childProcess
|
|
29
|
-
} catch (error) {
|
|
30
|
-
throw new VError(error, `Failed to launch ${name}`)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const wrap = (childProcess) => {
|
|
35
|
-
return {
|
|
36
|
-
childProcess,
|
|
37
|
-
on(event, listener) {
|
|
38
|
-
this.childProcess.on(event, listener)
|
|
39
|
-
},
|
|
40
|
-
off(event, listener) {
|
|
41
|
-
this.childProcess.off(event, listener)
|
|
42
|
-
},
|
|
43
|
-
send(message) {
|
|
44
|
-
this.childProcess.send(message)
|
|
45
|
-
},
|
|
46
|
-
sendAndTransfer(message, handle) {
|
|
47
|
-
this.childProcess.send(message, handle)
|
|
48
|
-
},
|
|
49
|
-
dispose() {
|
|
50
|
-
this.childProcess.kill()
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
}
|