赛普拉斯在命令日志中看不到请求

Cypress don't see requests in Command Log

我不能 'catch' 请求加入 Cypress。更重要的是,我看不到一些对 BE 的 XHR 请求,但它们在 DevTools 中。我添加了带箭头的屏幕截图以更好地描述问题。

我无法将我的项目上传到 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() 与获取请求一起使用,您需要按照此处所述进行操作: