Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cypress中的并行请求_Cypress - Fatal编程技术网

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

我想在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('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');
});