Skip to content

Commit

Permalink
add screenshots to build
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Jul 2, 2024
1 parent 080ee31 commit 04cf155
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ jobs:
run: |
npm ci
npm run check-ci
- name: Upload Artifact ⬆️
uses: actions/upload-artifact@v4
with:
path: ./screenshots/*.png
overwrite: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
.esm-cache
.tscache
screenshots
node_modules
package-lock.json
test/src/ts/dist/*
Expand Down
10 changes: 9 additions & 1 deletion test/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function getExamples(port) {
.map(f => ({
url: `http://localhost:${port}/examples/${f}`,
js: exampleInjectJS,
screenshot: true,
}));
}

Expand Down Expand Up @@ -65,7 +66,7 @@ async function test(port) {
...getExamples(port),
];

for (const {url, js} of testPages) {
for (const {url, js, screenshot} of testPages) {
waitingPromiseInfo = makePromiseInfo();
console.log(`===== [ ${url} ] =====`);
if (js) {
Expand All @@ -81,6 +82,13 @@ async function test(port) {
});
}
await waitingPromiseInfo.promise;
if (screenshot) {
const dir = 'screenshots';
fs.mkdirSync(dir, { recursive: true });
const name = /\/([a-z0-9_-]+).html/.exec(url);
const path = `${dir}/${name}.png`;
await page.screenshot({path});
}
}

await browser.close();
Expand Down

0 comments on commit 04cf155

Please sign in to comment.