diff --git a/cypress.config.js b/cypress.config.js index 16183b66..ea2953eb 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,3 +1,5 @@ +const RECORD = process.env.CYPRESS_RECORD === "true"; + export default { chromeWebSecurity: false, defaultCommandTimeout: 60000, @@ -17,4 +19,5 @@ export default { return config; }, }, + video: RECORD, }; diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index 02cdf907..78240e21 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -37,3 +37,31 @@ Cypress.Commands.add("login", (email, password) => { .click(); }); }); + +const RECORD = Cypress.env("RECORD") === true; + +if (RECORD) { + for (const command of [ + "visit", + "click", + "trigger", + "type", + "clear", + "reload", + ]) { + Cypress.Commands.overwrite(command, (originalFn, ...args) => { + const origVal = originalFn(...args); + + return new Promise((resolve) => { + setTimeout( + () => { + resolve(origVal); + }, + RECORD ? 2000 : 0, + ); + }); + }); + } + Cypress.config("viewportWidth", 2560); + Cypress.config("viewportHeight", 1440); +}