Cypress cant find spec files in folder I want

207 views Asked by At

I made a couple of cypress tests, however I can't seem to make cypress locate the spec files, it only locates the cypress\e2e folders/files (the tutorial folders), when I want them to access the tests\e2e\specs folder

I tried changing the cypress.json by:

{
  "pluginsFile": "tests/e2e/plugins/index.js",
  "integrationFolder": "tests" 
}

(Also tried "tests/e2e/specs" and "PintAndPillageFrontend/tests/e2e/specs") but that didn't seem to work

enter image description here

enter image description here

1

There are 1 answers

0
Tiana On BEST ANSWER

The thing that sticks out is you have cypress.json which is the old way (pre version 10) of configuring, yet the project is obvious structured for the current setup of Cypress.

Therefore, I'm going to recommend that in cypress.config.js (which should be in the project root) you add a specPattern setting that includes an array of all the paths that may contain a spec you want Cypress to run.

configuration#e2e

specPattern cypress/e2e/**/*.cy.{js,jsx,ts,tsx}
A String or Array of glob patterns of the test files to load.

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    baseUrl: 'http://localhost:1234',
    specPattern: [
      'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
      'printandpillage/tests/e2e/**/*.cy.js',
      'printandpillage/tests/e2e/**/*test.js',
    ],
  },
})

Sticking to one spec naming pattern such as *.cy.js will give Cypress and other people more clarity about your tests.