【发布时间】:2019-07-06 00:12:47
【问题描述】:
我正在使用 react 16.8.1、cypress 3.1.5 和 firebase 5.5.3 进行 e2e 测试。
目前我需要等待页面加载所有组件,然后运行测试,例如获取按钮并单击它。
在每次测试之前,程序会检查用户是否已登录,如果是,它将等待 firebase 发送一些 POST 和 GET 请求。
不幸的是,对于 GET 和 POST 请求,cypress 显示 CypressError: Timed out retrying: cy.wait() timed out waiting 100000ms for the 1st response to the route: 'googleGETRoute'. No response ever occurred.,这使得无法单击或继续测试。
在每个请求之前,我都会运行以下命令:
beforeEach(function () {
cy.server().route({ url: /https:\/\/.*google.*/, method: "POST" }).as("googleRoute");
cy.server().route({ url: /https:\/\/.*google.*/, method: "GET" }).as("googleGETRoute");
cy.visit('/event');
cy.wait('@googleRoute', xhr => {
cy.url().then((url) => {
if (url === 'http://localhost:3000/login') {
cy.loginByForm(testUserAccount, testUserPassword);
}
});
});
});
并删除一个事件:
it('should deleteEvent', function() {
cy.wait('@googleGETRoute', { responseTimeout:100000, log:true });
cy.wait('@googleRoute', { responseTimeout: 100000, log:true });
deleteEvent(event);
cy.contains(event.title).should('not.be.visible');
});
仍然没有来自 Firestore 的响应。我还检查了#1652 和#2374 几乎和这个问题一样。
以前有人遇到过这个问题吗?希望有任何帮助
【问题讨论】:
标签: javascript reactjs firebase e2e-testing cypress