This project uses Playwright for automated screenshot testing to detect visual changes in your personal website. This helps ensure that structural changes don’t accidentally break the UI and that intentional visual changes are properly captured.
The screenshot testing system is designed to support your agentic coding workflow by:
# Install Ruby dependencies
bundle install
# Install Node.js dependencies
npm install
# Install Playwright browsers
npx playwright install
# Run all screenshot tests (terminal output, perfect for agents)
npm run test
# Run tests with HTML report and open browser automatically
npm run test:html
# Run tests with UI (interactive mode)
npm run test:ui
# Run tests in headed mode (see browser)
npm run test:headed
# Update baseline screenshots (when you make intentional changes)
npm run test:update-snapshots
# Clean up old snapshots and test results
npm run test:clean
# Reset everything and create fresh baselines
npm run test:reset
# View existing test report (opens browser)
npm run test:report
The testing system is optimized for AI coding assistants:
npm run test
npm run test:html
npm run test:report
The tests are organized into focused categories:
main.spec.ts
)
main.spec.ts
)
main.spec.ts
)
When you make changes that shouldn’t affect the UI (migrations, adding metrics, etc.):
# 1. Make your structural changes
# 2. Run tests to verify no visual changes
npm run test
# If tests pass, your changes are safe to merge
# If tests fail, review the differences in the report
When you make changes that should affect the UI:
# 1. Make your visual changes
# 2. Update baseline screenshots
npm run test:update-snapshots
# 3. Run tests to verify the changes are captured
npm run test
# 4. Review the updated screenshots in the report
When adding new content or features:
# 1. Add your new feature
# 2. Update baselines to capture the new content
npm run test:update-snapshots
# 3. Verify the new content is properly captured
npm run test
The GitHub Actions workflow (.github/workflows/screenshot-tests.yml
) automatically:
When you make intentional visual changes:
npm run test:update-snapshots
npm run test
to verifyWhen you remove or rename tests, old snapshot files can accumulate:
# Clean up old snapshots and test results
npm run test:clean
# Reset everything and create fresh baselines
npm run test:reset
Best Practice: After removing tests, run npm run test:clean
to remove orphaned snapshot files.
waitForLoadState('networkidle')
for dynamic contentanimations: 'disabled'
bundle exec jekyll serve
works manuallyRun tests in headed mode to see what’s happening:
npm run test:headed
This opens a browser window so you can see the tests running and debug any issues.
tests/
├── main.spec.ts # Main test suite (clean & focused)
├── base-test.ts # Helper for clean syntax with automatic masking
└── helpers/ # (empty - helpers removed for simplicity)
test-results/ # Generated test results
playwright-report/ # HTML test reports
The test suite has been streamlined to focus on essential coverage:
All tests automatically ignore dynamic elements:
img[src$=".gif"]
).animated
, [data-animate]
).loading
, .spinner
)Tests use the takeScreenshot()
helper for clean, readable code:
// Simple screenshot
await takeScreenshot(page, 'homepage.png');
// Full page screenshot
await takeScreenshot(page, 'homepage.png', { fullPage: true });
// Element-specific screenshot
await takeScreenshot(page, 'header.png', { element: headerElement });
Add custom viewport tests in main.spec.ts
:
test('custom viewport', async ({ page, takeScreenshot }) => {
await page.setViewportSize({ width: 1200, height: 800 });
await takeScreenshot(page, 'custom-viewport.png', { fullPage: true });
});
Focus on specific elements using the helper:
const element = page.locator('.specific-element');
await takeScreenshot(page, 'element-name.png', { element });
The configuration tests on Chrome, Firefox, and Safari. Screenshots are taken for each browser to ensure cross-browser compatibility.
This screenshot testing system is designed to work seamlessly with AI coding assistants:
The system provides visual feedback that helps AI assistants understand the impact of code changes on the user interface.