Skip to content

Commit

Permalink
fix: screenshot generator
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKreil committed Sep 23, 2024
1 parent ed3bf33 commit f7aac9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install firefox
run: npx playwright install chromium

- name: Run screenshots
run: npm run screenshots
Expand Down
10 changes: 5 additions & 5 deletions scripts/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mkdirSync(path, { recursive: true });
colorScheme: 'light',
deviceScaleFactor: 1,
locale: 'de-DE',
viewport: { width: 642, height: 642 },
viewport: { width: 514, height: 514 },
timezoneId: 'Europe/Berlin'
};
const contextLight = await browser.newContext({ ...option, colorScheme: 'light' });
Expand All @@ -33,8 +33,8 @@ mkdirSync(path, { recursive: true });

async function screenShot(page: Page, suffix: string) {
console.log('generate screenshot: ' + name + ' - ' + suffix);
await page.goto('http://localhost:4173/' + name, { waitUntil: 'load' });
await wait(2);
await page.goto('http://localhost:4173/' + name, { waitUntil: 'networkidle' });
await wait(1);

const l = page.locator('.wrapper');
const clip = await l.boundingBox();
Expand All @@ -59,10 +59,10 @@ mkdirSync(path, { recursive: true });

async function npm_run_preview(): Promise<ChildProcess> {
const cp = spawn('npm', ['run', 'preview'], { stdio: 'pipe' });
await wait(1.5);
await wait(3);
return cp;
}

function wait(seconds: number): Promise<void> {
return new Promise<void>((r) => setTimeout(() => r(), seconds * 1000));
return new Promise<void>((r) => setTimeout(() => r(), seconds * 1500));
}

0 comments on commit f7aac9a

Please sign in to comment.