1***@163.com
1***@163.com
  • 发布:2023-06-25 15:06
  • 更新:2023-06-25 15:06
  • 阅读:134

自动化测试插件H5运行 一直报超时

分类:uni-app

jest.config.js配置如下:
module.exports = {
globalTeardown: '@dcloudio/uni-automator/dist/teardown.js',
testEnvironment: '@dcloudio/uni-automator/dist/environment.js',
bail: false,
verbose: true,
testEnvironmentOptions: {
compile: false,
h5: { // 为了节省测试时间,可以指定一个 H5 的 url 地址,若不指定,每次运行测试,会先 npm run dev:h5
url: "",
options: {
headless: false // 配置是否显示 puppeteer 测试窗口
}
},
"app-plus": { // 需要安装 HBuilderX
android: {
appid: "UNID41C604", //自定义基座测试需配置manifest.json中的appid
package: "com.joinbright.mf1", //自定义基座测试需配置Android包名
executablePath: "HBuilderX/plugins/launcher/base/android_base.apk" // apk 目录或自定义调试基座包路径
},
ios: {
// uuid 必须配置,目前仅支持模拟器,可以(xcrun simctl list)查看要使用的模拟器 uuid
id: "com.joinbright.mf1",
executablePath: "HBuilderX/plugins/launcher/base/Pandora_simulator.app" // ipa 目录
}
},
"mp-weixin": {
port: 9420, // 默认 9420
account: "", // 测试账号
args: "", // 指定开发者工具参数
cwd: "", // 指定开发者工具工作目录
launch: true, // 是否主动拉起开发者工具
teardown: "disconnect", // 可选值 "disconnect"|"close" 运行测试结束后,断开开发者工具或关闭开发者工具
remote: false, // 是否真机自动化测试
executablePath: "", // 开发者工具cli路径,默认会自动查找, windows: C:/Program Files (x86)/Tencent/微信web开发者工具/cli.bat", mac: /Applications/wechatwebdevtools.app/Contents/MacOS/cli
},
"mp-baidu": {
port: 9430, // 默认 9430
args: "", // 指定开发者工具参数
cwd: "", // 指定开发者工具工作目录
launch: true, // 是否主动拉起开发者工具
teardown: "disconnect", // 可选值 "disconnect"|"close" 运行测试结束后,断开开发者工具或关闭开发者工具
remote: false, // 是否真机自动化测试
executablePath: "", // 开发者工具cli路径,默认会自动查找
}
},
testTimeout: 20000,
reporters: [
'default'
],
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ["<rootDir>/src/pages/*/test.[jt]s?(x)"], // 测试文件目录
testPathIgnorePatterns: ['/node_modules/']
}
package.json依赖:

测试用例:
describe('/src/pages/baseCom/button/button', () => {
let page
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/baseCom/button/index')
await page.waitFor(7000)
})
it('button 页面标题', async () => {
page = await program.currentPage()
await page.waitFor(10000)
// console.log("------------------", page)
let view = await page.$('.mf1-demo-title')
// console.log(await view.text());
expect(await view.text()).toBe('演示效果')
})
});

运行报错:
Timeout - Async callback was not invoked within the 20000ms timeout specified by jest.setTimeout.

PS:testTimeout改成任何数都会报此错误

2023-06-25 15:06 负责人:无 分享
已邀请:

要回复问题请先登录注册