【发布时间】:2021-02-19 22:29:43
【问题描述】:
在 Cypress 中可以存根 XHR 响应,但我想捕获和修改 JSON 响应。
https://docs.cypress.io/guides/guides/network-requests.html#Stub-Responses https://docs.cypress.io/api/commands/route.html#With-Stubbing
我没有找到一个很好的例子来解释这一点。
在我的应用中有一个 API 调用:
/isHuman
响应是:
{"isHuman":true}
我想拦截这个调用并把 true 和另一个测试用 false
谁能提供这个?
上次编辑: 在本地主机上测试应用程序(我在其中定义 baseURL - localhost:3123),但是有对不同域的 api 调用(https://api.app.com/isHuman)。
我需要更改该 xhr 调用的响应。
【问题讨论】:
标签: json xmlhttprequest cypress