0

I wanted to move the cypress folder inside the test folder but all the resources are for the json config file. Cypress is updated and now uses a config.ts file and I am not able to add all the folder directories in it to get it working.

Found: Move cypress folder from the root of the project but it uses json config.

I do not want to create a cypress with Project "test".

Help appreciated!

Fody
  • 23,754
  • 3
  • 20
  • 37
Femn Dharamshi
  • 527
  • 1
  • 9
  • 25

2 Answers2

1

With Cypress now using a cypress.config.ts file, they've eliminated testFolders as a config option. Instead they suggest using the specPattern property.

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

export default defineConfig({
  e2e: {
    ... other properties
    specPattern: '/path/to/test/files/**/*.{js,jsx,ts,tsx}'
  }
});

By default, specPattern looks for cypress/e2e/**/*.cy.{js,jsx,ts,tsx} for e2e tests (and **/*.cy.{js,jsx,ts,tsx} for component (but excluding anything matching the e2e values.))

agoff
  • 5,818
  • 1
  • 7
  • 20
0

In the linked question this is the Cypress v9 config given by Gleb:

{
  "fixturesFolder": "test/cypress/fixtures",
  "integrationFolder": "test/cypress/integration",
  "pluginsFile": "test/cypress/plugins/index.js",
  "screenshotsFolder": "test/cypress/screenshots",
  "videosFolder": "test/cypress/videos",
  "downloadsFolder": "test/cypress/downloads",
  "supportFile": "test/cypress/support/index.js"
}

The equivalent in Cypress v10 would be:

const { defineConfig } = require('cypress')

module.exports = defineConfig({

  // same options as Cypress v9
  fixturesFolder: 'test/cypress/fixtures',
  screenshotsFolder: 'test/cypress/screenshots',
  videosFolder: 'test/cypress/videos',
  downloadsFolder: 'test/cypress/downloads',

  // these options are specific for e2e test
  e2e: {
    baseUrl: 'http://localhost:1234',

    supportFile: 'test/cypress/support/e2e.js',

    // import a legacy pluginsFile that has moved under /test folder
    setupNodeEvents(on, config) {
      return require('./test/cypress/plugins/index.js')(on, config)
    },

    // wildcard pattern for all tests 
    specPattern: 'test/cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',

    // OR named list of tests
    specPattern: [
      test/cypress/e2e/test1.cy.js,
      test/cypress/e2e/test2.cy.js,
    ]
  }
})
Fody
  • 23,754
  • 3
  • 20
  • 37