教程中脚本示例有bug
https://developers.weixin.qq.com/miniprogram/dev/devtools/auto/demo.html
获取page的方法再beforeAll函数中,由于beforeAll函数是异步执行,导致接下的来的测试函数读取page报undefined错误.
应改为等待page获取成功才执行接下来的测试函数:
beforeAll( () => {
return new Promise( function(resolve) {
(async ()=>{
miniProgram = await automator.launch({
projectPath: 'path/to/miniprogram-demo'
})
page = await miniProgram.reLaunch('/page/component/index')
await page.waitFor(500)
resolve()
})()
})
}, 30000)