cypress中的并行请求
我想在cypress中进行并行cypress中的并行请求,cypress,Cypress,我想在cypress中进行并行请求s。我为此定义了一个命令: const resetDb=()=>{ const apirl=`${Cypress.config().baseUrl}/api`; 柏树,答应我([ cy.request(`${apirl}/group/seed/resetDb`), cy.request(`${apirl}/auth/seed/resetDb`), cy.request(`${apirl}/email/seed/resetDb`), ]); }; add('res
请求
s。我为此定义了一个命令:
const resetDb=()=>{
const apirl=`${Cypress.config().baseUrl}/api`;
柏树,答应我([
cy.request(`${apirl}/group/seed/resetDb`),
cy.request(`${apirl}/auth/seed/resetDb`),
cy.request(`${apirl}/email/seed/resetDb`),
]);
};
add('resetDb',resetDb);
然而,它仍在按顺序提出这些请求。我做错了什么?我使用Cypress中的task解决了这个问题,它允许您使用nodejs API 在插件索引文件中,我定义了一个任务,如下所示:
const fetch=require('isomorphic-unfetch');
module.exports=on=>{
关于(‘任务’{
resetDb(){
常量apiUrl=`http://my.com/api`;
回报你的承诺([
fetch(`${apirl}/group/seed/resetDb`),
fetch(`${apirl}/auth/seed/resetDb`),
获取(`${apirl}/email/seed/resetDb`),
]);
},
});
};
它可以按如下方式使用:
之前(()=>{
返回cy.task('resetDb');
});