@lvce-editor/test-with-playwright 5.0.0 → 6.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,28 +1,23 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright",
3
- "version": "5.0.0",
4
- "description": "",
5
- "main": "src/main.js",
6
- "type": "module",
7
- "bin": "bin/test-with-playwright.js",
3
+ "version": "6.0.0",
4
+ "description": "CLI tool for running Playwright tests",
8
5
  "repository": {
9
6
  "type": "git",
10
7
  "url": "git@github.com:lvce-editor/test-with-playwright.git"
11
8
  },
12
- "keywords": [],
13
- "author": "Lvce Editor",
14
9
  "license": "MIT",
10
+ "author": "Lvce Editor",
11
+ "type": "module",
12
+ "main": "dist/main.js",
13
+ "bin": "bin/test-with-playwright.js",
15
14
  "dependencies": {
16
- "@lvce-editor/assert": "^1.4.0",
17
- "@lvce-editor/rpc": "^4.18.0",
18
- "@lvce-editor/verror": "^1.7.0",
19
- "minimist": "^1.2.8",
20
- "@lvce-editor/test-with-playwright-worker": "5.0.0",
21
- "@lvce-editor/test-worker": "^5.4.0"
15
+ "@lvce-editor/test-with-playwright-worker": "6.0.0",
16
+ "@lvce-editor/test-worker": "^5.10.0"
22
17
  },
23
- "devDependencies": {
24
- "@types/jest": "^30.0.0",
25
- "jest": "^30.1.1"
18
+ "devDependencies": {},
19
+ "engines": {
20
+ "node": ">=22"
26
21
  },
27
22
  "types": "api.d.ts"
28
23
  }
package/src/main.js DELETED
@@ -1,3 +0,0 @@
1
- import * as Main from './parts/Main/Main.js'
2
-
3
- Main.main()
@@ -1,2 +0,0 @@
1
- export const HandleResult = 'HandleResult'
2
- export const HandleFinalResult = 'HandleFinalResult'
@@ -1,8 +0,0 @@
1
- import * as CliCommandType from '../CliCommandType/CliCommandType.js'
2
- import * as HandleFinalResult from '../HandleFinalResult/HandleFinalResult.js'
3
- import * as HandleResult from '../HandleResult/HandleResult.js'
4
-
5
- export const commandMap = {
6
- [CliCommandType.HandleResult]: HandleResult.handleResult,
7
- [CliCommandType.HandleFinalResult]: HandleFinalResult.handleFinalResult,
8
- }
@@ -1,30 +0,0 @@
1
- export const getFinalResultMessage = (passed, skipped, failed, duration) => {
2
- if (passed === 0 && skipped === 0 && failed === 0) {
3
- return `no tests found`
4
- }
5
- if (passed === 0 && skipped === 0 && failed === 1) {
6
- return `${failed} test failed in ${duration}ms`
7
- }
8
- if (passed === 0 && skipped === 1 && failed === 0) {
9
- return `${skipped} test skipped in ${duration}ms`
10
- }
11
- if (passed === 0 && skipped === 1 && failed === 1) {
12
- return `${skipped} test skipped, ${failed} test failed in ${duration}ms`
13
- }
14
- if (passed === 1 && skipped === 0 && failed === 0) {
15
- return `${passed} test passed in ${duration}ms`
16
- }
17
- if (passed === 1 && skipped === 0 && failed === 1) {
18
- return `${passed} test passed, ${failed} test failed in ${duration}ms`
19
- }
20
- if (passed === 1 && skipped === 1 && failed === 0) {
21
- return `${passed} test passed, ${skipped} test skipped in ${duration}ms`
22
- }
23
- if (passed === 1 && skipped === 1 && failed === 1) {
24
- return `${passed} test passed, ${skipped} test skipped, ${failed} test failed in ${duration}ms`
25
- }
26
- if (passed > 1 && skipped === 0 && failed === 0) {
27
- return `${passed} tests passed in ${duration}ms`
28
- }
29
- return `${passed} tests passed, ${skipped} tests skipped, ${failed} tests failed in ${duration}ms`
30
- }
@@ -1,18 +0,0 @@
1
- import * as ParseCliArgs from '../ParseCliArgs/ParseCliArgs.js'
2
- import * as ParseEnv from '../ParseEnv/ParseEnv.js'
3
-
4
- const defaultOptions = {
5
- testPath: '',
6
- extensionPath: '',
7
- headless: false,
8
- }
9
-
10
- export const getOptions = ({ argv, env }) => {
11
- const parsedEnv = ParseEnv.parseEnv(env)
12
- const parsedArgs = ParseCliArgs.parseCliArgs(argv)
13
- return {
14
- ...defaultOptions,
15
- ...parsedEnv,
16
- ...parsedArgs,
17
- }
18
- }
@@ -1,3 +0,0 @@
1
- export const getTestWorkerPath = () => {
2
- return import.meta.resolve('@lvce-editor/test-with-playwright-worker')
3
- }
@@ -1,29 +0,0 @@
1
- import * as GetOptions from '../GetOptions/GetOptions.js'
2
- import * as RunAllTests from '../RunAllTests/RunAllTests.js'
3
- import * as GetTestWorkerPath from '../GetTestWorkerPath/GetTestWorkerPath.js'
4
-
5
- /**
6
- *
7
- * @param {{argv:string[], env:any, commandMap:any}} param0
8
- */
9
- export const handleCliArgs = async ({ argv, env, commandMap }) => {
10
- const cwd = process.cwd()
11
- const options = GetOptions.getOptions({ argv, env })
12
- const onlyExtension = options.onlyExtension
13
- const testPath = options.testPath
14
- const headless = options.headless
15
- const timeout = 30_000
16
- const testWorkerPath = GetTestWorkerPath.getTestWorkerPath()
17
-
18
- // TODO
19
- // console.log({ argv, env })
20
- await RunAllTests.runAllTests({
21
- onlyExtension,
22
- testPath,
23
- cwd,
24
- headless,
25
- timeout,
26
- commandMap,
27
- testWorkerPath,
28
- })
29
- }
@@ -1,11 +0,0 @@
1
- import * as GetFinalResultMessage from '../GetFinalResultMessage/GetFinalResultMessage.js'
2
-
3
- export const handleFinalResult = (finalResult) => {
4
- const { passed, failed, skipped, start, end } = finalResult
5
- const duration = end - start
6
- const message = GetFinalResultMessage.getFinalResultMessage(passed, skipped, failed, duration)
7
- console.info(message)
8
- if (failed > 0) {
9
- process.exitCode = 1
10
- }
11
- }
@@ -1,38 +0,0 @@
1
- import * as TestState from '../TestState/TestState.js'
2
-
3
- const getDuration = (start, end) => {
4
- return end - start
5
- }
6
-
7
- const handleResultPassed = (result) => {
8
- const { name, start, end } = result
9
- const duration = getDuration(start, end)
10
- console.info(`test passed ${name} in ${duration}ms`)
11
- }
12
-
13
- const handleResultSkipped = (result) => {
14
- const { name } = result
15
- console.info(`test skipped ${name}`)
16
- }
17
-
18
- const handleResultFailed = (result) => {
19
- const { name, error } = result
20
- console.error(`Test Failed ${name}: ${error}`)
21
- }
22
-
23
- export const handleResult = (result) => {
24
- const { status } = result
25
- switch (status) {
26
- case TestState.Pass:
27
- handleResultPassed(result)
28
- break
29
- case TestState.Skip:
30
- handleResultSkipped(result)
31
- break
32
- case TestState.Fail:
33
- handleResultFailed(result)
34
- break
35
- default:
36
- throw new Error(`unexpected test state: ${status}`)
37
- }
38
- }
@@ -1,9 +0,0 @@
1
- import * as CommandMap from '../CommandMap/CommandMap.js'
2
- import * as HandleCliArgs from '../HandleCliArgs/HandleCliArgs.js'
3
- import * as Process from '../Process/Process.js'
4
- import * as ProcessListeners from '../ProcessListeners/ProcessListeners.js'
5
-
6
- export const main = async () => {
7
- Process.on('uncaughtExceptionMonitor', ProcessListeners.handleUncaughtExceptionMonitor)
8
- await HandleCliArgs.handleCliArgs({ argv: Process.argv, env: Process.env, commandMap: CommandMap.commandMap })
9
- }
@@ -1,16 +0,0 @@
1
- import parseArgv from 'minimist'
2
-
3
- export const parseCliArgs = (argv) => {
4
- const parsed = parseArgv(argv)
5
- const result = Object.create(null)
6
- if (parsed.headless) {
7
- result.headless = true
8
- }
9
- if (parsed['only-extension']) {
10
- result.onlyExtension = parsed['only-extension']
11
- }
12
- if (parsed['test-path']) {
13
- result.testPath = parsed['test-path']
14
- }
15
- return result
16
- }
@@ -1,10 +0,0 @@
1
- export const parseEnv = (env) => {
2
- const options = Object.create(null)
3
- if (env['ONLY_EXTENSION']) {
4
- options['onlyExtension'] = env['ONLY_EXTENSION']
5
- }
6
- if (env['TEST_PATH']) {
7
- options['testPath'] = env['TEST_PATH']
8
- }
9
- return options
10
- }
@@ -1,20 +0,0 @@
1
- export const argv = process.argv
2
-
3
- export const env = process.env
4
-
5
- /**
6
- *
7
- * @param {number} code
8
- */
9
- export const exit = (code) => {
10
- process.exit(code)
11
- }
12
-
13
- /**
14
- *
15
- * @param {string} event
16
- * @param {any} listener
17
- */
18
- export const on = (event, listener) => {
19
- process.on(event, listener)
20
- }
@@ -1,3 +0,0 @@
1
- export const handleUncaughtExceptionMonitor = (error) => {
2
- console.log(`[test] uncaught exception ${error}`)
3
- }
@@ -1,6 +0,0 @@
1
- import { dirname, join } from 'node:path'
2
- import { fileURLToPath } from 'node:url'
3
-
4
- const __dirname = dirname(fileURLToPath(import.meta.url))
5
-
6
- export const root = join(__dirname, '..', '..', '..', '..', '..')
@@ -1,17 +0,0 @@
1
- import { NodeWorkerRpcParent } from '@lvce-editor/rpc'
2
- import * as TestWorkerCommandType from '../TestWorkerCommandType/TestWorkerCommandType.js'
3
-
4
- /**
5
- *
6
- * @param {{onlyExtension:string, testPath:string, cwd:string, headless:boolean, timeout:number, commandMap:any, testWorkerPath:string}} param0
7
- */
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,
12
- argv: [],
13
- commandMap,
14
- })
15
- await rpc.invoke(TestWorkerCommandType.RunAllTests, onlyExtension, testPath, cwd, headless, timeout)
16
- await rpc.dispose()
17
- }
@@ -1,3 +0,0 @@
1
- export const Pass = 1
2
- export const Skip = 2
3
- export const Fail = 3
@@ -1 +0,0 @@
1
- export const RunAllTests = 'RunAllTests'