【发布时间】:2022-11-10 22:21:10
【问题描述】:
我正在使用 Testcafe 编写功能测试。测试场景如下,有一个切换按钮,可根据 API 调用激活/停用
当我打开我的应用程序时,会进行一个返回值 ON/OFF 的 API 调用;基于此,拨动开关被激活或停用。
当用户再次单击该切换按钮时,我想拦截该呼叫。
长话短说:
- 用户登录
- XYZ API 被调用,它给出了响应
- 基于该响应,切换按钮被激活
- 然后用户将点击切换按钮
- 现在应该再次调用 XYZ API,这将返回 OFF
await t.navigateTo(`${url}`); await t .click(myPage.toggleSwitch) .addRequestHooks(myPage.xyzAPI.respond([{ valueBar: "ON" } ])) .expect(myPage.toggleSwitch.checked) .eql(true); });```
【问题讨论】:
标签: testing automated-tests testcafe functional-testing