【发布时间】:2018-02-26 11:26:57
【问题描述】:
我有以下规格文件:
describe('The First Page', () => {
beforeEach(() => {
cy.server();
cy.route({
method : 'GET',
url: '**/v3/user/*',
status: 204,
response: {
id: 1,
firstName: 'Dev',
lastName: 'Dev',
email: 'dev1@gmail.com',
},
});
});
it('successfully loads', () => {
cy.visit('/dashboard/account');
});
});
通过阅读the cypress documentation,我认为这是我们可以将 http 请求存根到 Web 服务器的方式。尽管对 'api/v3/user' 的 http 请求返回 504 状态,但这并不像我预期的那样工作。有没有办法使用 cypress 的任何命令来模拟/存根 http 请求?我正在使用
whatwg-fetch
模块以便在我的应用程序中发出请求。
【问题讨论】:
标签: tdd integration-testing e2e-testing cypress