按照文档 小程序自动化-常用示例-伪造请求结果跑示例代码,为什么得不到示例的log输出?
开发工具版本:stable 1.03.2006090 系统版本:windows10 文档链接:https://developers.weixin.qq.com/miniprogram/dev/devtools/auto/example.html#%E4%BC%AA%E9%80%A0%E8%AF%B7%E6%B1%82%E7%BB%93%E6%9E%9C 示例里的log输出是 'test',但我实际运行得到的输出是 'ok',这是为什么? 完整代码如下 ```javascript const automator = require('miniprogram-automator') describe('api', () => { let miniProgram beforeAll(async () => { miniProgram = await automator.launch({ projectPath: 'E:\\******\\******' }) }, 30000) afterAll(async () => { await miniProgram.disconnect() }) it('request', async () => { const mockData = [ { rule: 'testRequest', result: { data: 'test', cookies: [], header: {}, statusCode: 200, }, }, ] await miniProgram.mockWxMethod( 'request', function (obj, data) { for (let i = 0, len = data.length; i < len; i++) { const item = data[i] const rule = new RegExp(item.rule) if (rule.test(obj.url)) { return item.result } // 没命中规则的真实访问后台 return new Promise(resolve => { obj.success = res => resolve(res) obj.fail = res => resolve(res) this.origin(obj) }) } }, mockData, ) const result = await miniProgram.callWxMethod('request', { url: 'https://14592619.qcloud.la/testRequest', }) console.log(result.data) // -> 这里期望输出是'test',但实际输出是'ok' await miniProgram.restoreWxMethod('request') }, 30000) }) ```