Cypress recording

1k Views Asked by At

just wanted to ask if this is possible to change the location folder for recorded file? I am running tests for two different applications, one after another, and when tests are finished for both of them, I can only access the latest recording.

Thanks in advance!

2

There are 2 best solutions below

1
On BEST ANSWER

You can add videosFolder attribute in your cypress config file with the folder path.

videosFolder: 'cypress/videos_project_2'

You can override the videosFolder path from the CLI, something like this:

npx cypress run --config videosFolder=cypress/videos_project_2

In your package.json, create two scripts like this:

"scripts": {
  "test:project1": "npx cypress run --config videosFolder=cypress/videos_project_1",
  "test:project2": "npx cypress run --config videosFolder=cypress/videos_project_2",
}

Then as per the project, directly run the commands:

npm run test:project1
//or
npm run test:project2
0
On

The easiest way is to set trashAssetsBeforeRuns.

See Videos

Cypress clears any existing videos before a cypress run. If you do not want to clear your videos folder before a run, you can set trashAssetsBeforeRuns to false.

cypress.config.js

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

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