Skip to content

Commit

Permalink
chore: add option to record tests with cypress to generate demo videos
Browse files Browse the repository at this point in the history
  • Loading branch information
rdubigny committed May 21, 2024
1 parent 3222377 commit a9ecce2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const RECORD = process.env.CYPRESS_RECORD === "true";

export default {
chromeWebSecurity: false,
defaultCommandTimeout: 60000,
Expand All @@ -17,4 +19,5 @@ export default {
return config;
},
},
video: RECORD,
};
28 changes: 28 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit a9ecce2

Please sign in to comment.