切换vitest-browser
This commit is contained in:
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
@@ -1,3 +1,2 @@
|
||||
{
|
||||
"recommendations": ["Orta.vscode-jest"]
|
||||
}
|
45
.vscode/launch.json
vendored
45
.vscode/launch.json
vendored
@@ -4,33 +4,30 @@
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest All",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["--runInBand"],
|
||||
"name": "Run Vitest Browser",
|
||||
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
|
||||
}
|
||||
"args": [
|
||||
"--inspect-brk",
|
||||
"--browser",
|
||||
"--no-file-parallelism"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest Current File",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": [
|
||||
"--runTestsByPath",
|
||||
"${relativeFile}",
|
||||
"--config",
|
||||
"jest.config.js"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
|
||||
"type": "chrome",
|
||||
"request": "attach",
|
||||
"name": "Attach to Vitest Browser",
|
||||
"port": 9229
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Debug Vitest Browser",
|
||||
"configurations": [
|
||||
"Attach to Vitest Browser",
|
||||
"Run Vitest Browser"
|
||||
],
|
||||
"stopAll": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -1,3 +1,2 @@
|
||||
{
|
||||
"jest.useJest30": true
|
||||
}
|
21
package.json
21
package.json
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "cut-abstractions",
|
||||
"type": "module",
|
||||
"version": "0.1.5",
|
||||
"description": "",
|
||||
"files": [
|
||||
@@ -11,40 +12,28 @@
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"release": "pnpm pack --pack-destination ./dist-packs",
|
||||
"clean": "rimraf ./dist",
|
||||
"test": "vitest",
|
||||
"test:run": "vitest run",
|
||||
"test:browser": "vitest --browser"
|
||||
"test": "vitest"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"packageManager": "pnpm@9.1.1+sha1.09ada6cd05003e0ced25fb716f9fda4063ec2e3b",
|
||||
"devDependencies": {
|
||||
"@peculiar/webcrypto": "^1.5.0",
|
||||
"@swc/core": "^1.12.4",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@vitest/browser": "^3.2.4",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"@vitest/ui": "^3.2.4",
|
||||
"cadapi": "http://gitea.cf/MES-FE/webcad-api/archive/0.0.60.tar.gz",
|
||||
"happy-dom": "^18.0.1",
|
||||
"js-angusj-clipper": "^1.0.4",
|
||||
"playwright": "^1.54.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^1.6.1"
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/preset-typescript": "^7.27.1",
|
||||
"@types/node": "^22.16.3",
|
||||
"comlink": "^4.4.2",
|
||||
"import-meta-resolve": "^4.1.0",
|
||||
"three": "^0.178.0",
|
||||
"vite": "^5.0.0",
|
||||
"webworker": "^0.8.4"
|
||||
"three": "^0.178.0"
|
||||
}
|
||||
}
|
1508
pnpm-lock.yaml
generated
Normal file
1508
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,12 @@
|
||||
import { describe, it, expect, test } from 'vitest';
|
||||
import { test, it, expect } from 'vitest';
|
||||
import { DemoParser } from '../samples/demoParser';
|
||||
import { ProcessorModule, StepControllerProcessor } from '../src/device';
|
||||
import { ProcessorManager } from '../src/device';
|
||||
import { demoHandleGroupCutting } from '../samples/demoDatahandle/demoDataHandle1';
|
||||
import testJson from "./test.json"
|
||||
import { Worker, parentPort } from 'worker_threads';
|
||||
import { UniversalWorker } from '../samples/WorkerHelper';
|
||||
describe('demoParser', () => {
|
||||
// import { ProcessorModule, StepControllerProcessor } from '../src/device';
|
||||
// import { ProcessorManager } from '../src/device';
|
||||
// import { demoHandleGroupCutting } from '../samples/demoDatahandle/demoDataHandle1';
|
||||
// import testJson from "./test.json"
|
||||
// import { Worker, parentPort } from 'worker_threads';
|
||||
// import { UniversalWorker } from '../samples/WorkerHelper';
|
||||
test('demoParser', () => {
|
||||
const text = `FSTART
|
||||
TD 5
|
||||
G0 X100 Y100 Z10 F8000
|
||||
@@ -23,163 +23,163 @@ FEND
|
||||
|
||||
})
|
||||
|
||||
describe('data', async () => {
|
||||
const sysConfig = {
|
||||
placeStyle: 1,
|
||||
boardWidth: 2440,
|
||||
boardLength: 1220,
|
||||
// 测试刀库数据
|
||||
knifeList: [knifeData, knifeData1, knifeData2]
|
||||
}
|
||||
const json = testJson
|
||||
// 创建处理器集合
|
||||
const processorManager = new ProcessorManager<any, any>();
|
||||
// 这里省略了 选择处理器的环节 --这里选了demo开料机
|
||||
const cuttingHandle = new demoHandleGroupCutting()
|
||||
// 注册处理器
|
||||
processorManager.registerProcessor(cuttingHandle.processorName, cuttingHandle.processor)
|
||||
// 使用XX处理器 会返回激活【正在使用】的 处理器
|
||||
let processor = processorManager.useProcessor(cuttingHandle.processorName)
|
||||
// 或者 这样 获取 正在使用的处理器 注:若未执行useProcessor 将会返回 undefind
|
||||
// processor = processorManager.getCurrentProcessor()
|
||||
/** 处理器配置加载 */
|
||||
processor.updateModuleConfig(sysConfig)
|
||||
const res = await processor.process(json)
|
||||
// console.log('处理器所有流程都结束了', res);
|
||||
})
|
||||
|
||||
/** demo 刀具数据 */
|
||||
export const knifeData = {
|
||||
"isEnabled": true,
|
||||
"axleId": 2,
|
||||
"knifeId": 2,
|
||||
"processFace": "",
|
||||
"knifeName": "T1",
|
||||
"knifeType": 3,
|
||||
"ability": [
|
||||
5
|
||||
],
|
||||
"diameter": 5,
|
||||
"length": 20,
|
||||
"sawThiness": 7,
|
||||
"sawDirection": 2,
|
||||
"processDirection": 4,
|
||||
"speed": 0,
|
||||
"stepDepth": 0,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"offsetZ": 0,
|
||||
"baseX": 0,
|
||||
"baseY": 0,
|
||||
"isModularDrill": false,
|
||||
"isPreStartEnabled": false,
|
||||
"preStartAheadActionCount": 5,
|
||||
"isPreStartToolChangeDelay": false,
|
||||
"preStartToolChangeDelayCode": "",
|
||||
"isAxisStartCodePostpost": false,
|
||||
"isAxisStopCodePrepose": false,
|
||||
"drillGroupCode": "",
|
||||
"axisStartCode": "M03 S18000\n",
|
||||
"knifeStartCode": `M06 T1\nG43 H1\n`,
|
||||
"drillGroupStartCode": "T1",
|
||||
"drillGroupEndCode": "",
|
||||
"knifeStopCode": "",
|
||||
"axisStopCode": "M05\n",
|
||||
"preStartActionDeferCode": "",
|
||||
"useHolesGroupKnife": false,
|
||||
"preStartActionStepsLimit": "",
|
||||
"knifeNo": "",
|
||||
"editable": true,
|
||||
"isDefaultCutKnife": false,
|
||||
"isPreStartChangeKnifeDefer": false
|
||||
}
|
||||
export const knifeData1 = {
|
||||
"isEnabled": true,
|
||||
"axleId": 2,
|
||||
"knifeId": 2,
|
||||
"processFace": "",
|
||||
"knifeName": "T2",
|
||||
"knifeType": 3,
|
||||
"ability": [
|
||||
5
|
||||
],
|
||||
"diameter": 6,
|
||||
"length": 20,
|
||||
"sawThiness": 7,
|
||||
"sawDirection": 2,
|
||||
"processDirection": 4,
|
||||
"speed": 0,
|
||||
"stepDepth": 0,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"offsetZ": 0,
|
||||
"baseX": 0,
|
||||
"baseY": 0,
|
||||
"isModularDrill": false,
|
||||
"isPreStartEnabled": false,
|
||||
"preStartAheadActionCount": 5,
|
||||
"isPreStartToolChangeDelay": false,
|
||||
"preStartToolChangeDelayCode": "",
|
||||
"isAxisStartCodePostpost": false,
|
||||
"isAxisStopCodePrepose": false,
|
||||
"drillGroupCode": "",
|
||||
"axisStartCode": "M03 S18000\n",
|
||||
"knifeStartCode": `M06 T2\nG43 H2\n`,
|
||||
"drillGroupStartCode": "T2",
|
||||
"drillGroupEndCode": "",
|
||||
"knifeStopCode": "",
|
||||
"axisStopCode": "M05\n",
|
||||
"preStartActionDeferCode": "",
|
||||
"useHolesGroupKnife": false,
|
||||
"preStartActionStepsLimit": "",
|
||||
"knifeNo": "",
|
||||
"editable": true,
|
||||
"isDefaultCutKnife": false,
|
||||
"isPreStartChangeKnifeDefer": false
|
||||
}
|
||||
export const knifeData2 = {
|
||||
"isEnabled": true,
|
||||
"axleId": 2,
|
||||
"knifeId": 2,
|
||||
"processFace": "",
|
||||
"knifeName": "T3",
|
||||
"knifeType": 3,
|
||||
"ability": [
|
||||
5
|
||||
],
|
||||
"diameter": 6,
|
||||
"length": 20,
|
||||
"sawThiness": 7,
|
||||
"sawDirection": 2,
|
||||
"processDirection": 4,
|
||||
"speed": 0,
|
||||
"stepDepth": 0,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"offsetZ": 0,
|
||||
"baseX": 0,
|
||||
"baseY": 0,
|
||||
"isModularDrill": false,
|
||||
"isPreStartEnabled": false,
|
||||
"preStartAheadActionCount": 5,
|
||||
"isPreStartToolChangeDelay": false,
|
||||
"preStartToolChangeDelayCode": "",
|
||||
"isAxisStartCodePostpost": false,
|
||||
"isAxisStopCodePrepose": false,
|
||||
"drillGroupCode": "",
|
||||
|
||||
"axisStartCode": "M03 S18000\n",
|
||||
"knifeStartCode": `M06 T2\nG43 H2\n`,
|
||||
"drillGroupStartCode": "T3",
|
||||
"drillGroupEndCode": "",
|
||||
"knifeStopCode": "",
|
||||
"axisStopCode": "M05\n",
|
||||
|
||||
"preStartActionDeferCode": "",
|
||||
"useHolesGroupKnife": false,
|
||||
"preStartActionStepsLimit": "",
|
||||
"knifeNo": "",
|
||||
"editable": true,
|
||||
"isDefaultCutKnife": false,
|
||||
"isPreStartChangeKnifeDefer": false
|
||||
}
|
||||
// describe('data', async () => {
|
||||
// const sysConfig = {
|
||||
// placeStyle: 1,
|
||||
// boardWidth: 2440,
|
||||
// boardLength: 1220,
|
||||
// // 测试刀库数据
|
||||
// knifeList: [knifeData, knifeData1, knifeData2]
|
||||
// }
|
||||
// const json = testJson
|
||||
// // 创建处理器集合
|
||||
// const processorManager = new ProcessorManager<any, any>();
|
||||
// // 这里省略了 选择处理器的环节 --这里选了demo开料机
|
||||
// const cuttingHandle = new demoHandleGroupCutting()
|
||||
// // 注册处理器
|
||||
// processorManager.registerProcessor(cuttingHandle.processorName, cuttingHandle.processor)
|
||||
// // 使用XX处理器 会返回激活【正在使用】的 处理器
|
||||
// let processor = processorManager.useProcessor(cuttingHandle.processorName)
|
||||
// // 或者 这样 获取 正在使用的处理器 注:若未执行useProcessor 将会返回 undefind
|
||||
// // processor = processorManager.getCurrentProcessor()
|
||||
// /** 处理器配置加载 */
|
||||
// processor.updateModuleConfig(sysConfig)
|
||||
// const res = await processor.process(json)
|
||||
// // console.log('处理器所有流程都结束了', res);
|
||||
// })
|
||||
//
|
||||
// /** demo 刀具数据 */
|
||||
// export const knifeData = {
|
||||
// "isEnabled": true,
|
||||
// "axleId": 2,
|
||||
// "knifeId": 2,
|
||||
// "processFace": "",
|
||||
// "knifeName": "T1",
|
||||
// "knifeType": 3,
|
||||
// "ability": [
|
||||
// 5
|
||||
// ],
|
||||
// "diameter": 5,
|
||||
// "length": 20,
|
||||
// "sawThiness": 7,
|
||||
// "sawDirection": 2,
|
||||
// "processDirection": 4,
|
||||
// "speed": 0,
|
||||
// "stepDepth": 0,
|
||||
// "offsetX": 0,
|
||||
// "offsetY": 0,
|
||||
// "offsetZ": 0,
|
||||
// "baseX": 0,
|
||||
// "baseY": 0,
|
||||
// "isModularDrill": false,
|
||||
// "isPreStartEnabled": false,
|
||||
// "preStartAheadActionCount": 5,
|
||||
// "isPreStartToolChangeDelay": false,
|
||||
// "preStartToolChangeDelayCode": "",
|
||||
// "isAxisStartCodePostpost": false,
|
||||
// "isAxisStopCodePrepose": false,
|
||||
// "drillGroupCode": "",
|
||||
// "axisStartCode": "M03 S18000\n",
|
||||
// "knifeStartCode": `M06 T1\nG43 H1\n`,
|
||||
// "drillGroupStartCode": "T1",
|
||||
// "drillGroupEndCode": "",
|
||||
// "knifeStopCode": "",
|
||||
// "axisStopCode": "M05\n",
|
||||
// "preStartActionDeferCode": "",
|
||||
// "useHolesGroupKnife": false,
|
||||
// "preStartActionStepsLimit": "",
|
||||
// "knifeNo": "",
|
||||
// "editable": true,
|
||||
// "isDefaultCutKnife": false,
|
||||
// "isPreStartChangeKnifeDefer": false
|
||||
// }
|
||||
// export const knifeData1 = {
|
||||
// "isEnabled": true,
|
||||
// "axleId": 2,
|
||||
// "knifeId": 2,
|
||||
// "processFace": "",
|
||||
// "knifeName": "T2",
|
||||
// "knifeType": 3,
|
||||
// "ability": [
|
||||
// 5
|
||||
// ],
|
||||
// "diameter": 6,
|
||||
// "length": 20,
|
||||
// "sawThiness": 7,
|
||||
// "sawDirection": 2,
|
||||
// "processDirection": 4,
|
||||
// "speed": 0,
|
||||
// "stepDepth": 0,
|
||||
// "offsetX": 0,
|
||||
// "offsetY": 0,
|
||||
// "offsetZ": 0,
|
||||
// "baseX": 0,
|
||||
// "baseY": 0,
|
||||
// "isModularDrill": false,
|
||||
// "isPreStartEnabled": false,
|
||||
// "preStartAheadActionCount": 5,
|
||||
// "isPreStartToolChangeDelay": false,
|
||||
// "preStartToolChangeDelayCode": "",
|
||||
// "isAxisStartCodePostpost": false,
|
||||
// "isAxisStopCodePrepose": false,
|
||||
// "drillGroupCode": "",
|
||||
// "axisStartCode": "M03 S18000\n",
|
||||
// "knifeStartCode": `M06 T2\nG43 H2\n`,
|
||||
// "drillGroupStartCode": "T2",
|
||||
// "drillGroupEndCode": "",
|
||||
// "knifeStopCode": "",
|
||||
// "axisStopCode": "M05\n",
|
||||
// "preStartActionDeferCode": "",
|
||||
// "useHolesGroupKnife": false,
|
||||
// "preStartActionStepsLimit": "",
|
||||
// "knifeNo": "",
|
||||
// "editable": true,
|
||||
// "isDefaultCutKnife": false,
|
||||
// "isPreStartChangeKnifeDefer": false
|
||||
// }
|
||||
// export const knifeData2 = {
|
||||
// "isEnabled": true,
|
||||
// "axleId": 2,
|
||||
// "knifeId": 2,
|
||||
// "processFace": "",
|
||||
// "knifeName": "T3",
|
||||
// "knifeType": 3,
|
||||
// "ability": [
|
||||
// 5
|
||||
// ],
|
||||
// "diameter": 6,
|
||||
// "length": 20,
|
||||
// "sawThiness": 7,
|
||||
// "sawDirection": 2,
|
||||
// "processDirection": 4,
|
||||
// "speed": 0,
|
||||
// "stepDepth": 0,
|
||||
// "offsetX": 0,
|
||||
// "offsetY": 0,
|
||||
// "offsetZ": 0,
|
||||
// "baseX": 0,
|
||||
// "baseY": 0,
|
||||
// "isModularDrill": false,
|
||||
// "isPreStartEnabled": false,
|
||||
// "preStartAheadActionCount": 5,
|
||||
// "isPreStartToolChangeDelay": false,
|
||||
// "preStartToolChangeDelayCode": "",
|
||||
// "isAxisStartCodePostpost": false,
|
||||
// "isAxisStopCodePrepose": false,
|
||||
// "drillGroupCode": "",
|
||||
//
|
||||
// "axisStartCode": "M03 S18000\n",
|
||||
// "knifeStartCode": `M06 T2\nG43 H2\n`,
|
||||
// "drillGroupStartCode": "T3",
|
||||
// "drillGroupEndCode": "",
|
||||
// "knifeStopCode": "",
|
||||
// "axisStopCode": "M05\n",
|
||||
//
|
||||
// "preStartActionDeferCode": "",
|
||||
// "useHolesGroupKnife": false,
|
||||
// "preStartActionStepsLimit": "",
|
||||
// "knifeNo": "",
|
||||
// "editable": true,
|
||||
// "isDefaultCutKnife": false,
|
||||
// "isPreStartChangeKnifeDefer": false
|
||||
// }
|
||||
|
@@ -16,7 +16,7 @@
|
||||
// },
|
||||
// "include": ["src/**/*", "tests/**/*"], // 包含测试文件
|
||||
"compilerOptions": {
|
||||
"types": [],
|
||||
"types": ["@vitest/browser/providers/playwright"],
|
||||
"resolveJsonModule": true, // 允许导入 .json 文件
|
||||
"esModuleInterop": true, // 确保 CommonJS/ESM 兼容
|
||||
"module": "ESNext", // 推荐使用 ESM
|
||||
|
11
vitest-example/HelloWorld.test.ts
Normal file
11
vitest-example/HelloWorld.test.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { expect, test } from 'vitest'
|
||||
import { getByText } from '@testing-library/dom'
|
||||
import HelloWorld from './HelloWorld.js'
|
||||
|
||||
test('renders name', () => {
|
||||
const parent = HelloWorld({ name: 'Vitest' })
|
||||
document.body.appendChild(parent)
|
||||
|
||||
const element = getByText(parent, 'Hello Vitest!')
|
||||
expect(element).toBeInTheDocument()
|
||||
})
|
9
vitest-example/HelloWorld.ts
Normal file
9
vitest-example/HelloWorld.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default function HelloWorld({ name }: { name: string }): HTMLDivElement {
|
||||
const parent = document.createElement('div')
|
||||
|
||||
const h1 = document.createElement('h1')
|
||||
h1.textContent = 'Hello ' + name + '!'
|
||||
parent.appendChild(h1)
|
||||
|
||||
return parent
|
||||
}
|
14
vitest.config.ts
Normal file
14
vitest.config.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
provider: 'playwright',
|
||||
// https://vitest.dev/guide/browser/playwright
|
||||
instances: [
|
||||
{ browser: 'chromium' },
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user