赛普拉斯不匹配存根路由

时间:2020-04-07 10:33:18

标签: testing cypress e2e-testing

我正在我的应用代码中这样做:

const xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.gizconnection.com/labels", true);
xhr.setRequestHeader("Authorization", "Bearer " + authService.getToken());
xhr.send(null);

在我的测试中,我有:

it.only("test", () => {
  cy.server();
  cy.route("GET", "https://api.gizconnection.com/labels", [
    { text: "foo" }
  ]);
});

但不匹配,我要疯了。

在CY的日志中,我看到了请求,但说不匹配:

enter image description here

我在Chrome的devtools中看到了它,但是我得到的响应是来自服务器的真实响应:

enter image description here

enter image description here

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

如文档here中所述,使用复杂的字符串时,URL必须完全匹配。我建议使用glob模式选项:

AudioSettings.outputSampleRate