@lvce-editor/test-with-playwright 0.0.16 → 0.0.17

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": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "",
5
5
  "main": "src/main.js",
6
6
  "types": "src/main.d.ts",
@@ -16,6 +16,7 @@
16
16
  "dependencies": {
17
17
  "@playwright/test": "^1.25.0",
18
18
  "get-port": "^6.1.2",
19
+ "minimist": "^1.2.6",
19
20
  "read-pkg-up": "^9.1.0"
20
21
  }
21
22
  }
package/src/all.js CHANGED
@@ -3,6 +3,7 @@ import { readdirSync } from 'node:fs'
3
3
  import { basename, join } from 'node:path'
4
4
  import { performance } from 'node:perf_hooks'
5
5
  import { closeAll, getRoot, runTest, startAll, state } from './main.js'
6
+ import parseArgv from 'minimist'
6
7
 
7
8
  /**
8
9
  * @param {string} root
@@ -51,13 +52,30 @@ const executeSingleTest = async (page, url) => {
51
52
  }
52
53
  }
53
54
 
55
+ /**
56
+ *
57
+ * @param {any} options
58
+ */
59
+ const getEnv = (options) => {
60
+ const env = Object.create(null)
61
+ if (options['only-extension']) {
62
+ env['ONLY_EXTENSION'] = options['only-extension']
63
+ }
64
+ if (options['test-path']) {
65
+ env['TEST_PATH'] = options['test-path']
66
+ }
67
+ return env
68
+ }
69
+
54
70
  const main = async () => {
55
71
  try {
72
+ const argv = process.argv.slice(2)
73
+ const options = parseArgv(argv)
56
74
  let skipped = 0
57
75
  let passed = 0
76
+ const env = getEnv(options)
58
77
  const start = performance.now()
59
- const { page, port } = await startAll()
60
- console.info('SETUP COMPLETE')
78
+ const { page, port } = await startAll(env)
61
79
  const root = await getRoot()
62
80
  const testFiles = await getTestFiles(join(root, 'src'))
63
81
  console.log({ testFiles })
package/src/main.js CHANGED
@@ -111,11 +111,11 @@ export const runTest = async ({ name, fn }) => {
111
111
  console.info(`[test] passed ${name} in ${duration}ms`)
112
112
  }
113
113
 
114
- export const startAll = async () => {
114
+ export const startAll = async (env) => {
115
115
  const port = await getPort()
116
116
  await launchServer({
117
117
  port,
118
- env: {},
118
+ env,
119
119
  folder: '',
120
120
  })
121
121
  state.port = port