Search code examples
vue.jscypresscypress-component-test-runner

Vue Cypress Component Test Runner - location of test files


I've added the Cypress Vue Component Test runner to an existing Vue app and I want all the test files to be in the same directory as the components. However, whatever I put in my cypress.json file seems to be ignored and cypress always wants to look in the default integration folder.

In my cypress.json file I have:

{
    "component": {
      "componentFolder": "src",
      "testFiles": "**/*.spec.ts",
      "testMatch": [
        "**/src/**/*.spec.[jt]s?(x)"
      ]
    },
}

but when I run

npm run cy:run:chrome

I get:

> vue-myapp@0.1.0 cy:run:chrome
> cypress run --browser chrome

Can't run because no spec files were found.

We searched for any files inside of this folder:

/Users/richardshergold/Projects/vue-myapp/cypress/integration

Solution

  • You can change the default folder that Cypress looks in for tests using integrationFolder in your cypress.json. This value defaults to cypress/integration.

    Even when adding a testFiles field, Cypress will restrict that search to the integrationFolder value.

    ...
    "integrationFolder": "/path/to/tests/folder",
    ...