@lvce-editor/test-with-playwright-worker 1.2.0 → 1.4.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-worker",
3
- "version": "1.2.0",
3
+ "version": "1.4.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
- "@playwright/test": "^1.46.1",
16
+ "@lvce-editor/verror": "^1.4.0",
17
+ "@lvce-editor/assert": "^1.3.0",
18
+ "@playwright/test": "^1.47.2",
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
- import { AssertionError } from '../AssertionError/AssertionError.js'
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 VError from 'verror'
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
- // @ts-ignore
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
  }
@@ -10,6 +10,7 @@ export const handleCliArgs = async ({ argv, env }) => {
10
10
  const testPath = env.TEST_PATH || ''
11
11
  const headless = argv.includes('--headless')
12
12
  // TODO
13
+ // @ts-ignore
13
14
  await RunAllTests.runAllTests({
14
15
  extensionPath,
15
16
  testPath,
@@ -0,0 +1,8 @@
1
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
2
+
3
+ /**
4
+ * @param {any} error
5
+ */
6
+ export const isEnoentError = (error) => {
7
+ return error && error.code === ErrorCodes.ENOENT
8
+ }
@@ -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 instanceof AssertionError) {
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 { browser, page, child, port } = await SetupTests.setupTests({
26
+ const { page, child, port } = await SetupTests.setupTests({
27
27
  signal,
28
28
  headless,
29
29
  onlyExtension: extensionPath,
@@ -1,6 +1,5 @@
1
1
  import { expect } from '@playwright/test'
2
2
  import { basename } from 'node:path'
3
- import { join } from 'path'
4
3
  import * as GetTestState from '../GetTestState/GetTestState.js'
5
4
 
6
5
  /**
@@ -1,6 +0,0 @@
1
- export class AssertionError extends Error {
2
- constructor(message) {
3
- super(message)
4
- this.name = 'AssertionError'
5
- }
6
- }