gpt4 book ai didi

javascript - Cypress 在命令日志中看不到请求

转载 作者:行者123 更新时间:2023-12-02 21:05:31 26 4
gpt4 key购买 nike

我无法“捕获”与 Cypress 合作的请求。更重要的是,我看不到一些 XHR 请求,但它们在 DevTools 中。我添加了带有箭头的屏幕截图以更好地描述问题。 enter image description here

我无法将我的项目上传到公共(public)存储库,但也许您可以根据测试本身获得一些想法。我没有任何 beforeEach 等。

it('should generate the right request for password change', () => {
cy.visit(`/courses/reset-password?token=${token}&userId=${userId}`);
cy.server();
cy.route('POST', '/auth/local/reset-password').as('resetRequest');
cy.get('#password').type(password);
cy.get('#confirmPassword').type(password);
cy.get('button[type="submit"]').click();
console.log('at the end');
cy.wait('@resetRequest').then((request) => {
// never get here
console.log('fff', request);
console.log('requestBody', request.requestBody);
expect(request.body.newPassword).to.eq(password);
expect(request.body.token).to.eq(token);
expect(request.body.userId).to.eq(userId);
});

});

如果有人有任何想法 - 请与我分享:)

最佳答案

为了能够将 cy.server() 和 cy.route() 与获取请求一起使用,您需要按照此处所述进行操作: https://stackoverflow.com/a/49088084/9947826

关于javascript - Cypress 在命令日志中看不到请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61235428/

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