easy way of running different groups of Cypress tests

冷暖自知 提交于 2021-02-10 12:32:07

问题


So I have a project dir under that I have my Cypress dir under that I have two dir's with different tests I run. Right now in my project dir I have a cypress.json that has the setting "integrationFolder": "cypress/test_tests",when I issue the command npx cypress run it gets the dir from the integrationFolder setting in the .json file but if I want to run the tests from a different dir I have to edit the cypress.json file and set the integrationFolder to the other dir, is there a way I can specify which dir I want Cypress to pick the tests from?


回答1:


Yes, as explained here

cypress run --spec 'tests/folderOne/**/*'

or

cypress run --spec 'tests/folderTwo/**/*'



回答2:


Added config into your cypress.json

"integrationFolder": "./",

then both your folders can be supported by Cypress runner.

To run them you can add the commands in package.json:

"cypress-test1": "cypress run --spec \"cypress/folder1/*.spec.js\""

"cypress-test2": "cypress run --spec \"cypress/folder2/*.spec.js\""

so you can run either folder by a short command, like:

yarn cypress-test1



来源:https://stackoverflow.com/questions/50993299/easy-way-of-running-different-groups-of-cypress-tests

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!