设置Cypress并行运行
修改.circleci文件夹下的config.yml文件,在working_directory:~/app
下增加parallelism:2
配置项,同时更改package.json文件,加入--parallel
参数
"scripts":{
"cy:run":"yarn cypress run",
"debug":"yarn cypress open",
"start":"node server.js",
"test":"START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3002 cy:run"
"cy:run":"cypress run --record --key cypress run --record --key a5004313-38e2-4b57-b0f6-2f7eda0c2b79 --parallel"
然后提交到Github,再次执行测试,在Dashboard上便可以查看到并行执行的结果
Cypress还提供了分组功能,通过加标签的形式,多次运行后便可以通过标签在Dashboard中进行分组筛选,语法很简单,在运行中添加参数--group
即可
//将login模块的所有用例分为Login组
cypress run --record --group Login --spec 'cypress/integration/login//*.js'
也可以通过配置文件进行分组设置,修改package.json文件
"scripts":{
"ModuleRun":"node moduleRunIndex.js",
"debug":"yarn cypress open",
"start":"node server.js",
"test":"START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3002 cy-run",
"cy-run":"yarn cy:run1 && yarn cy:run2",
"cy:run1":"yarn cypress run --record --key a5004313-38e2-4b57-b0f6-2f7eda0c2b79 --group group1 --spec \"cypress/integration/first-spec.js\" --parallel",
"cy:run2":"yarn cypress run --record --key a5004313-38e2-4b57-b0f6-2f7eda0c2b79 --group group2 --spec \"cypress/integration/third-spec.js\" --parallel",
然后在Dashboard中便是如下结果