gpt4 book ai didi

Cypress 在提交表单时取消 api 请求

转载 作者:行者123 更新时间:2023-12-03 19:16:18 24 4
gpt4 key购买 nike

您好,我有一个表单提交到图形 ql api。当我单击提交按钮时,我看到 cypress 在能够获得响应之前取消了对 api 的请求之一。知道如何防止这种情况吗?
编辑:我试过添加 cy.wait(6000);或 cy.wait('apiAlias'),点击后提交,都没有帮助。

Text

最佳答案

通过阻止表单提交的默认行为来修复此问题 here

function preventFormSubmitDefault(selector) {
cy.get(selector).then(form$ => {
form$.on("submit", e => {
e.preventDefault();
});
});
}

然后在测试中:
    preventFormSubmitDefault("form");
cy.get('[data-test="submitButton"]').click();

关于 Cypress 在提交表单时取消 api 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60385480/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com