
- 发布:2024-05-05 13:59
- 更新:2025-02-13 11:33
- 阅读:197
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Windows 10 家庭中文版
HBuilderX类型: 正式
HBuilderX版本号: 4.14
手机系统: 全部
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
jest.config.js文件代码
复制代码module.exports = {
testTimeout: 10000,
reporters: [
'default'
],
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ["<rootDir>/pages/**/*test.[jt]s?(x)"],
testPathIgnorePatterns: ['/node_modules/'],
testEnvironmentOptions: {
compile: true,
"app-plus": { // 需要安装 HBuilderX
android: {
appid: "__UNI__AA3CE00", //自定义基座测试需配置manifest.json中的appid
package: "uni.UNIAA3CE00", //自定义基座测试需配置Android包名
executablePath: "E:\\Hello uni-app\\unpackage\\debug\\android_debug.apk" // apk 目录或自定义调试基座包路径
}
}
}
}
env.js文件代码
复制代码module.exports = {
"is-custom-runtime": false,
"compile": true,
"h5": {
"options": {
"headless": true
},
"executablePath": ""
},
"mp-weixin": {
"port": 9420,
"account": "",
"args": "",
"cwd": "",
"launch": true,
"teardown": "disconnect",
"remote": false,
"executablePath": ""
},
"app-plus": {
"android": {
"id": "192.168.10.5",
"executablePath": "E:\\HBuilderX\\HBuilderX\\plugins\\launcher\\base\\android_base.apk"
},
"version": "E:\\HBuilderX\\HBuilderX\\plugins\\launcher\\base\\version.txt",
"ios": {
"id": "",
"executablePath": ""
}
}
}
jest.config.js文件代码
复制代码module.exports = {
testTimeout: 10000,
reporters: [
'default'
],
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ["<rootDir>/pages/**/*test.[jt]s?(x)"],
testPathIgnorePatterns: ['/node_modules/'],
testEnvironmentOptions: {
compile: true,
"app-plus": { // 需要安装 HBuilderX
android: {
appid: "__UNI__AA3CE00", //自定义基座测试需配置manifest.json中的appid
package: "uni.UNIAA3CE00", //自定义基座测试需配置Android包名
executablePath: "E:\\Hello uni-app\\unpackage\\debug\\android_debug.apk" // apk 目录或自定义调试基座包路径
}
}
}
}
env.js文件代码
复制代码module.exports = {
"is-custom-runtime": false,
"compile": true,
"h5": {
"options": {
"headless": true
},
"executablePath": ""
},
"mp-weixin": {
"port": 9420,
"account": "",
"args": "",
"cwd": "",
"launch": true,
"teardown": "disconnect",
"remote": false,
"executablePath": ""
},
"app-plus": {
"android": {
"id": "192.168.10.5",
"executablePath": "E:\\HBuilderX\\HBuilderX\\plugins\\launcher\\base\\android_base.apk"
},
"version": "E:\\HBuilderX\\HBuilderX\\plugins\\launcher\\base\\version.txt",
"ios": {
"id": "",
"executablePath": ""
}
}
}
操作步骤:
下载Hello uniapp模版,打包自定义基座,修改jest.config.js的appid、package、executablePath三个属性,运行自动化插件到android
下载Hello uniapp模版,打包自定义基座,修改jest.config.js的appid、package、executablePath三个属性,运行自动化插件到android
预期结果:
使用自定义基座进行自动化测试
使用自定义基座进行自动化测试
实际结果:
使用默认基座进行自动化测试
使用默认基座进行自动化测试
bug描述:
按文档配置jest.config.js的appid、package、executablePath三个属性后依旧不会启动自定义基座进行自动化测试。在Hello uni-app中依旧有此问题
2***@qq.com (作者)
https://ask.dcloud.net.cn/article/41545这有解决办法。记得更新插件到最新版本,在env.js里改,不要在jest.config.js里改
这是相关的文档https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/#env-js-uni-test-custom-env
2025-03-20 22:59