Bill Flow
Bill Flow

Reputation: 21

easy way of running different groups of Cypress tests

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?

Upvotes: 2

Views: 6354

Answers (2)

kuceb
kuceb

Reputation: 18023

Yes, as explained here

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

or

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

Upvotes: 2

Tony Qin
Tony Qin

Reputation: 191

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

Upvotes: 1

Related Questions