reactjs - 使用 waitForResponse 时剧作家测试失败
问题描述
当我使用命令“page.waitForResponse”时,我的编剧测试从未通过。虽然执行了 API 调用,并且可以在 chrome 的网络选项卡中看到。我将开玩笑超时设置为 30000,但这似乎不是问题。
it("Test", async () => {
await page.goto("http://localhost:8080/")
await Promise.all([
await page.waitForResponse("https://development/my/call", {
timeout: 1000,
}),
page.click("css=body")
])
})
网络
url: https://development/my/call
Status: 200
Type: xhr
错误
Async callback was not invoked within the 30000 ms timeout specified by jest.setTimeout.Error
解决方案
问题可能出在您的问题中未包含的内容中。
通常,您必须在导致调用的操作发生之前开始等待响应。假设操作是在页面某处单击,然后您要键入:
await Promise.all([
page.waitForResponse("http://localhost:8060/my/call"),
page.click('.someButton'),
]);
试试这个,它可能会解决你的问题。
推荐阅读
- python-3.x - 在 3D 阵列中替换 2D 子阵列
- javascript - 如何在 google drive api 中复制文件夹?
- python - 在循环中忙碌时杀死一个python进程
- php - 在 wordpress 的单独页面上提交 2 个表单
- java - 我无法找到 tdmext.jar 的 maven 依赖项
- math - 如何找到参与求和运算的整数的实际值
- arrays - 从 3D Numpy 数组的一维切片
- sql - 我们可以在 postgresql 中使用什么来代替 dba_role_privs?
- neo4j - 如何使用 Cypher 在 Neo4j 中找到一系列连接节点的头部?
- python - 提高数据序列化函数运行时内存