Skip to content

Commit b84a2bd

Browse files
committed
chore: allow tests to record and upload screencasts
1 parent b4dd1a1 commit b84a2bd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.github/workflows/functional-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ jobs:
167167
if: ${{ always() }}
168168
with:
169169
name: screenshots-${{matrix.scenario}}
170-
path: ./ci/tests/puppeteer/screenshots/*.png
170+
path: ./ci/tests/puppeteer/screenshots/*.*
171171
if-no-files-found: ignore
172172
retention-days: 2
173173
##########################################################################
@@ -222,7 +222,7 @@ jobs:
222222
if: ${{ always() }}
223223
with:
224224
name: screenshots-${{matrix.scenario}}
225-
path: ./ci/tests/puppeteer/screenshots/*.png
225+
path: ./ci/tests/puppeteer/screenshots/*.*
226226
if-no-files-found: ignore
227227
retention-days: 2
228228
##########################################################################
@@ -277,7 +277,7 @@ jobs:
277277
if: ${{ always() }}
278278
with:
279279
name: screenshots-${{matrix.scenario}}
280-
path: ./ci/tests/puppeteer/screenshots/*.png
280+
path: ./ci/tests/puppeteer/screenshots/*.*
281281
if-no-files-found: ignore
282282
retention-days: 2
283283
##########################################################################

ci/tests/puppeteer/cas.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,21 @@ exports.screenshot = async (page) => {
892892
}
893893
};
894894

895+
exports.recordPage = async (page) => {
896+
const screenshotsDir = path.join(__dirname, "screenshots");
897+
if (!fs.existsSync(screenshotsDir)) {
898+
fs.mkdirSync(screenshotsDir);
899+
await this.log(`Created screenshots directory: ${screenshotsDir}`);
900+
}
901+
const index = Date.now();
902+
const filePath = path.join(screenshotsDir, `${process.env.SCENARIO}-${index}.mp4`);
903+
await this.logg(`Recording page at ${filePath}`);
904+
return page.screencast({
905+
path: filePath,
906+
format: "mp4"
907+
});
908+
};
909+
895910
exports.isCiEnvironment = async () => process.env.CI !== undefined && process.env.CI === "true";
896911

897912
exports.isNotCiEnvironment = async () => !this.isCiEnvironment();

0 commit comments

Comments
 (0)