Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Using Playwright to test my static sites

The author describes using Playwright, a browser automation tool, to write and run tests for their static websites. They explain how Playwright enables them to programmatically interact with pages, verify content, and check for broken links or rendering issues, making testing more reliable than manual checks.

Background

- **Playwright** is an open-source browser automation library (by Microsoft) that lets you programmatically control a real web browser (Chromium, Firefox, WebKit). It's commonly used for end-to-end web testing but also for scraping or taking screenshots. - **Static sites** are websites built from pre-generated HTML/CSS/JS files (no server-side logic or database). Common tools include Jekyll, Hugo, and 11ty. The author's site runs on the Jekyll static site generator, hosted on GitHub Pages. - This post walks through adding Playwright-based tests to catch issues before deploying: checking that image HTML is well-formed, every internal link resolves, and every image/`<source>` URL points to an actual file — tasks that static site generators can't automatically verify. - The author previously used the simpler **html-proofer** gem (a Ruby-based link checker), but wanted to test richer browser interactions like JavaScript-driven content and responsive images. Playwright's ability to fully load pages and evaluate JavaScript makes those checks possible.

Related stories