Douglas
Douglas

Reputation: 51

Cypress Testing Organization

Is it possible to have my unit tests created with Cypress in my component directories and/or is it possible to link them as opposed to having them in the Cypress folder structure?

Upvotes: 3

Views: 643

Answers (2)

Garrett
Garrett

Reputation: 4414

You can have Cypress grab tests that are spread across multiple directories by modifying your cypress.json.

For example, if you want to grab all tests from the src/pages and src/components directories that have .spec. in them, you could update your cypress.json to be:

{
  "integrationFolder": "./",
  "testFiles": "{./src/pages/**/*.spec.*,./src/components/**/*.spec.*}"
}

(from this discussion)

Upvotes: 1

P D
P D

Reputation: 840

From Cypress documentation:

Test files are located in cypress/integration by default, but can be configured to another directory.

Then on 'Configuration' documentation page you may find option integrationFolder, which specifies the path to the folder containing integration test files, and by default its value is cypress/integration.

So you just have to change integrationFolder option in cypress.json file.

Upvotes: 0

Related Questions