0

in v13.3.0, after you install Cypress.js into your repo, it creates these four default directories:

  • /cypress/e2e
  • /cypress/fixtures
  • /cypress/support
  • /cypress/downloads

the first one is where it expects your e2e tests to go and it watches its contents on-fly.

but what if i want to have my e2e tests stored elsewhere?

1

2 Answers 2

-1

in the root of your repo Cypress will place cypress.config.js

default content of it is:

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});

i have my e2e tests in: tests/cypress/

so i added the specPattern line, which made it working for me (after i saved the file):

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
    specPattern: 'tests/cypress/**/*.cy.js',
  },
});

any file(s) with extensions .cy.js in the directory tests/cypress/ or in further sub-directories, will match.

official documentation:

https://docs.cypress.io/guides/references/configuration#e2e

https://docs.cypress.io/guides/component-testing/component-framework-configuration#Spec-Pattern-for-Component-Tests

-1

In Cypress.js, you can change the default path for your end-to-end (E2E) tests by specifying the integrationFolder option in your configuration file (cypress.json or cypress.env.json). By default, Cypress looks for test files inside the cypress/integration directory. If you want to change this path, follow these steps:

Create a configuration file (if you don't have one):

If you don't have a cypress.json file in your project, you can create one in your project's root directory.

Specify the custom integration folder path:

Inside your cypress.json file, add the integrationFolder option with the desired path to your E2E test files. For example: { "integrationFolder": "path/to/your/tests" }

Replace "path/to/your/tests" with the actual path to the directory where your E2E test files are located.

Run Cypress with the custom configuration:

Once you've set the custom integration folder path in your cypress.json file, Cypress will look for test files in the specified directory when you run your tests.

You can run Cypress using the following command in your terminal or command prompt: npx cypress open or npx cypress run Cypress will now use the custom path you specified for your E2E tests.

Remember to adjust the path in the integrationfolder option based on your project's directory structure. This allows you to organize your tests in a way that makes sense for your project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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