3

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?

2 Answers 2

1

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)

0

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.

1
  • This sounds like you still have to have your tests in a single directory as opposed to having them living in the many different component directories.
    – Garrett
    Commented Sep 14, 2021 at 2:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.