Skip to content

Commit 8b4505c

Browse files
committed
add screenshots to build
1 parent b04426a commit 8b4505c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ jobs:
2222
run: |
2323
npm ci
2424
npm run check-ci
25+
26+
- name: Upload Artifact ⬆️
27+
uses: actions/upload-artifact@v4
28+
with:
29+
path: ./screenshots/*.png
30+
overwrite: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.DS_Store
33
.esm-cache
44
.tscache
5+
screenshots
56
node_modules
67
package-lock.json
78
test/src/ts/dist/*

test/puppeteer.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function getExamples(port) {
1717
.map(f => ({
1818
url: `http://localhost:${port}/examples/${f}`,
1919
js: exampleInjectJS,
20+
screenshot: true,
2021
}));
2122
}
2223

@@ -65,7 +66,7 @@ async function test(port) {
6566
...getExamples(port),
6667
];
6768

68-
for (const {url, js} of testPages) {
69+
for (const {url, js, screenshot} of testPages) {
6970
waitingPromiseInfo = makePromiseInfo();
7071
console.log(`===== [ ${url} ] =====`);
7172
if (js) {
@@ -81,6 +82,13 @@ async function test(port) {
8182
});
8283
}
8384
await waitingPromiseInfo.promise;
85+
if (screenshot) {
86+
const dir = 'screenshots';
87+
fs.mkdirSync(dir, { recursive: true });
88+
const name = /\/([a-z0-9_-]+).html/.exec(url);
89+
const path = `${dir}/${name}.png`;
90+
await page.screenshot({path});
91+
}
8492
}
8593

8694
await browser.close();

0 commit comments

Comments
 (0)