-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcapture.mjs
More file actions
21 lines (16 loc) · 823 Bytes
/
Copy pathcapture.mjs
File metadata and controls
21 lines (16 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import puppeteer from 'puppeteer';
async function capture() {
const browser = await puppeteer.launch();
const page = (await browser.pages())[0];
await page.setViewport({ width: 1280, height: 800 });
await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'light' }]);
await page.goto('http://localhost:10000', { waitUntil: 'networkidle2' });
await page.screenshot({ path: 'preview/home_light.png' });
// Try to toggle dark mode if possible or take another page shot
await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'dark' }]);
await page.reload({ waitUntil: 'networkidle2' });
await page.screenshot({ path: 'preview/home_dark.png' });
await browser.close();
console.log("Screenshots captured in preview directory.");
}
capture().catch(console.error);