@lvce-editor/test-with-playwright-worker 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 +4 -2
- package/src/parts/Assert/Assert.js +1 -59
- package/src/parts/GetTests/GetTests.js +3 -5
- package/src/parts/HandleCliArgs/HandleCliArgs.js +1 -0
- package/src/parts/IsEnoentError/IsEnoentError.js +8 -0
- package/src/parts/PrettyError/PrettyError.js +1 -2
- package/src/parts/RunAllTests/RunAllTests.js +1 -1
- package/src/parts/RunTest/RunTest.js +0 -1
- package/src/parts/AssertionError/AssertionError.js +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/test-with-playwright-worker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@
|
|
16
|
+
"@lvce-editor/verror": "^1.4.0",
|
|
17
|
+
"@lvce-editor/assert": "^1.3.0",
|
|
18
|
+
"@playwright/test": "^1.48.1",
|
|
17
19
|
"get-port": "^7.1.0",
|
|
18
20
|
"minimist": "^1.2.8",
|
|
19
21
|
"read-pkg-up": "^11.0.0",
|
|
@@ -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'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { VError } from '@lvce-editor/verror'
|
|
1
2
|
import { readdir } from 'fs/promises'
|
|
2
|
-
import
|
|
3
|
-
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
|
|
3
|
+
import * as IsEnoentError from '../IsEnoentError/IsEnoentError.js'
|
|
4
4
|
import * as IsTestFile from '../IsTestFile/IsTestFile.js'
|
|
5
5
|
import { NoTestFilesFoundError } from '../NoTestFilesFoundError/NoTestFilesFoundError.js'
|
|
6
6
|
|
|
@@ -12,11 +12,9 @@ export const getTests = async (testSrc) => {
|
|
|
12
12
|
const dirents = await readdir(testSrc)
|
|
13
13
|
return dirents.filter(IsTestFile.isTestFile)
|
|
14
14
|
} catch (error) {
|
|
15
|
-
|
|
16
|
-
if (error && error.code === ErrorCodes.ENOENT) {
|
|
15
|
+
if (IsEnoentError.isEnoentError(error)) {
|
|
17
16
|
throw new NoTestFilesFoundError(testSrc)
|
|
18
17
|
}
|
|
19
|
-
// @ts-ignore
|
|
20
18
|
throw new VError(error, `Failed to get test files`)
|
|
21
19
|
}
|
|
22
20
|
}
|
|
@@ -2,7 +2,6 @@ import { codeFrameColumns } from '@babel/code-frame'
|
|
|
2
2
|
import { LinesAndColumns } from 'lines-and-columns'
|
|
3
3
|
import { readFileSync } from 'node:fs'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
|
-
import { AssertionError } from '../AssertionError/AssertionError.js'
|
|
6
5
|
import * as CleanStack from '../CleanStack/CleanStack.js'
|
|
7
6
|
import * as EncodingType from '../EncodingType/EncodingType.js'
|
|
8
7
|
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
|
|
@@ -62,7 +61,7 @@ const prepareModuleNotFoundError = (error) => {
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
const getStackLinesToCut = (error) => {
|
|
65
|
-
if (error
|
|
64
|
+
if (error && error.name === 'AssertionError') {
|
|
66
65
|
return 1
|
|
67
66
|
}
|
|
68
67
|
return 0
|
|
@@ -23,7 +23,7 @@ export const runAllTests = async (ipc, extensionPath, testPath, cwd, headless, t
|
|
|
23
23
|
Assert.number(timeout)
|
|
24
24
|
const controller = new AbortController()
|
|
25
25
|
const signal = controller.signal
|
|
26
|
-
const {
|
|
26
|
+
const { page, child, port } = await SetupTests.setupTests({
|
|
27
27
|
signal,
|
|
28
28
|
headless,
|
|
29
29
|
onlyExtension: extensionPath,
|