In this article, we will discuss how we can record videos of tests in cypress.
Video Rec Setup And Format:
- Cypress records video of specs on the command of cypress run.
- Note that video record does not happen during cypress open.
- If video recording is not needed, it can be turned off in the config file.

- Video recording can be enabled or disabled with true or false.
- Videos are, by default, stored in the cypress/videos folder.
- We can change the directory destination using the videosFolder: option in config.
- Cypress compresses the video by default in 32 CRF.
- videoCompression: option can be used in config to enter the personal format.
Cloud:
- After every successful run, videos are processed, compressed, and uploaded to the cypress cloud after every spec runs.
- As we discussed, changing this behavior only to pass specs is an option.
Auto Clear:
- Cypress auto-clears any existing video before the cypress run and uploads the new run spec video recording.
- If videos are needed to be present without clearing before a run, we can set the trashAssetsBeforeRuns: option to false.
Encoding:
- If a spec file has a long run, there will be a time gap between a finished spec and a new spec.
- During this, the cypress encodes the captured video and uploads it to the cypress cloud.
- If video encoding is slow or takes time, we can modify it using the videoCompression: option.
const { defineConfig } = require('cypress')
module.exports = defineConfig({
videoCompression: 20,
})
- We can also disable compression for fast compression.
const { defineConfig } = require('cypress')
module.exports = defineConfig({
videoCompression: false,
})
Example:
- Let us record this test.
describe('Type Command',()=>{
before(() => {
cy.visit('https://www.programsbuzz.com/user/login')
})
it('Type Username And Password',()=>{
cy.get('form').within(()=>{
cy.userName('Ashman')
cy.get('#edit-name').tab()
cy.passWord('shazam@123')
})
})
})

- We can see the video has been generated after the spec run.
