Skip to content

Commit 290cb93

Browse files
committed
refactor(test): update test configuration and dependencies
1 parent c78de9a commit 290cb93

File tree

9 files changed

+182
-161
lines changed

9 files changed

+182
-161
lines changed

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ export default defineConfig({
4040
test: {
4141
environment: 'uniapp',
4242
environmentOptions: {
43-
compile: true,
44-
platform: 'h5', // 测试平台
45-
projectPath: './src', // manifest.json 所在目录
46-
port: 5121,
47-
h5: {
48-
url: 'http://localhost:5180/', // 改成你的 H5 服务器地址
49-
options: {
50-
headless: false, // 是否无头模式
51-
},
52-
},
43+
uniapp: {
44+
compile: true,
45+
platform: 'mp-weixin',
46+
projectPath: './src',
47+
port: 5121,
48+
}
5349
},
5450
},
5551
})

global.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
import 'vitest/node'
2+
3+
declare module 'vitest/node' {
4+
interface EnvironmentOptions {
5+
/**
6+
* uniapp 测试环境选项,详情请参考[uni-app 自动化测试](https://uniapp.dcloud.net.cn/worktile/auto/quick-start.html#jestconfigjs)
7+
*/
8+
uniapp?: {
9+
/**
10+
* H5 测试选项
11+
*/
12+
'h5': {
13+
[x: string]: unknown
14+
}
15+
/**
16+
* app-plus 测试选项, 需要安装 HBuilderX
17+
*/
18+
'app-plus': {
19+
[x: string]: unknown
20+
}
21+
/**
22+
* 微信小程序测试选项
23+
*/
24+
'mp-weixin': {
25+
[x: string]: unknown
26+
}
27+
/**
28+
* 支付宝小程序测试选项
29+
*/
30+
'mp-alipay': {
31+
[x: string]: unknown
32+
}
33+
}
34+
}
35+
}
36+
137
declare global {
238
/**
339
* Element 模块提供了控制页面元素的方法
@@ -442,4 +478,5 @@ declare global {
442478
exposeFunction: (name: string, bindingFunction: (() => unknown)) => Promise<void>
443479
}
444480
}
481+
445482
export {}

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
"typecheck": "tsc",
4040
"prepare": "simple-git-hooks"
4141
},
42+
"peerDependencies": {
43+
"@dcloudio/uni-automator": "*",
44+
"vitest": "*"
45+
},
4246
"devDependencies": {
4347
"@antfu/eslint-config": "^6.6.1",
4448
"@antfu/ni": "^28.0.0",

playground/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@
3838
"@dcloudio/uni-stacktracey": "3.0.0-4080720251210001",
3939
"@dcloudio/vite-plugin-uni": "3.0.0-4080720251210001",
4040
"@mini-types/alipay": "^3.0.14",
41-
"@types/node": "^25.2.2",
41+
"@playwright/test": "^1.58.2",
42+
"@types/node": "^25.0.1",
4243
"@uni-helper/plugin-uni": "0.1.0",
4344
"@uni-helper/unh": "^0.2.10",
4445
"@uni-helper/uni-types": "^1.0.0-alpha.7",
4546
"@vue/runtime-core": "3.4.21",
4647
"@vue/tsconfig": "^0.8.1",
4748
"miniprogram-api-typings": "^5.0.0",
49+
"playwright": "^1.58.2",
4850
"sass": "1.64.2",
4951
"typescript": "^5.9.3",
5052
"vite": "5.2.8",

playground/tsconfig.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
"@uni-helper/uni-types",
2121
"vitest-environment-uniapp/types"
2222
],
23+
"allowImportingTsExtensions": true,
24+
"allowJs": true,
2325
"strict": true,
24-
"noImplicitThis": true,
26+
"strictNullChecks": true,
27+
"noUnusedLocals": true,
28+
"noEmit": true,
2529
"esModuleInterop": true,
2630
"forceConsistentCasingInFileNames": true,
27-
"verbatimModuleSyntax": true,
2831
"skipLibCheck": true
2932
},
30-
"include": [
31-
"**/*.d.ts",
32-
"src/**/*.ts",
33-
"src/**/*.tsx",
34-
"src/**/*.jsx",
35-
"src/**/*.vue"
33+
"exclude": [
34+
"dist",
35+
"node_modules"
3636
],
3737
"vueCompilerOptions": {
3838
"plugins": ["@uni-helper/uni-types/volar-plugin"]

playground/vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ export default defineConfig({
1313
// https://uni-helper.js.org/plugin-uni
1414
Uni(),
1515
],
16-
1716
})

playground/vitest.config.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ export default defineConfig({
44
test: {
55
environment: 'uniapp',
66
environmentOptions: {
7-
compile: true,
8-
platform: 'mp-weixin',
9-
projectPath: './src',
10-
port: 5121,
11-
h5: {
12-
url: 'http://localhost:5180/', // 改成你的 H5 服务器地址
13-
options: {
14-
headless: false, //
15-
},
7+
uniapp: {
8+
compile: true,
9+
platform: 'mp-weixin',
10+
projectPath: './src',
11+
port: 5121,
1612
},
1713
},
1814
},

0 commit comments

Comments
 (0)