javascript - 赛普拉斯 cy.route2 没有收到请求
问题描述
我有一个登录页面,我想用 Cypress 进行测试,并且我想利用新功能的动态响应route2
功能。我对作品的原始测试cy.route()
:
cy.server();
cy.route({method: 'POST', url: '/api/login', status: 401, response: {
code: 401,
message: "Invalid credentials"
}}).as('login_xhr');
但cy.route2()
不是:
cy.route2('/api/login', {
statusCode: 401,
body: {
code: 401,
message: "Invalid credentials"
}
}).as('login_xhr');
我在这里做错了什么?对于这两种情况,检查的其余部分如下所示:
cy.get('.tab-pane.active input[name="email"]').type('test@exmaple.com');
cy.get('.tab-pane.active input[name="password"]').type('wrong_pw');
cy.contains('button', 'Login').click();
cy.wait('@login_xhr');
cy.route2()
请求也被中止:
解决方案
推荐阅读
- react-native - React Native 将参数从 Screen 传递到 Tab Navigator
- apache-spark - 如何使用 Pyspark 从 mongodb 中仅提取特定行?
- javascript - 桌面通知仅适用于 Chrome 浏览器?
- arrays - “字符串”类型上不存在属性“地图”
- java - 如何使用 Java 从 Firebase 实时数据库中删除数据?
- python - 按日期对多个数据框中的列求和
- powershell - 如何在 PowerShell 中检索 IIS 网站的 SSL 证书
- php - 如何检查多维数组中是否存在两个值?
- jquery - onRemove 事件未触发
- python - 对 LSTM 模型的 Jacobian 使用梯度磁带 - Python