cy.intercept('http://example.com/myPage1**').as('myPage1');
,但是,cy.wait('@myPage1').its('response.statusCode').should('eq',200);
正在计时,测试案例失败。
可以用url的正则表达式捕获它。
您不需要指定基本部分
http://example.com
。 chars
/
和?
\
表示字面特征。
cy.intercept(/\/myPage1\?/).as('myPage1')
近来,
cy.intercept({pathname: '**/myPage1'}, {}).as('myPage1')
用baseurl测试:
const { defineConfig } = require("cypress");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
baseUrl: 'http://192.168.43.82/font-end/#/'
},
});
应用程序获取
fetch('http://192.168.43.82/rest/api/myPage1?id=598dccc6&startDate=10/01/2023&endDate=11/01/2023')