LLM-first developer tool for generating Component Catalogues
The catalogue integrates with Playwright for visual regression testing. Screenshots are captured for each scenario across themes and breakpoints.
npm install -D @playwright/test
npx playwright install
In catalogue.config.ts:
export default {
playwright: {
breakpoints: [
{ name: 'mobile', width: 375, height: 667 },
{ name: 'tablet', width: 768, height: 1024 },
{ name: 'desktop', width: 1280, height: 800 },
],
themes: ['light', 'dark'],
screenshotDir: './screenshots',
},
};
catalogue test
This will:
When you intentionally change component appearance:
catalogue test --update
Run with browser visible:
catalogue test --headed
Tests are generated for each combination of:
light and dark (configurable)For example, with 10 scenarios, 2 themes, and 3 breakpoints:
10 × 2 × 3 = 60 screenshot tests
Each scenario has a harness URL for direct access:
/#/harness/<scenario-id>
| Parameter | Description | Example |
|---|---|---|
theme |
Theme override | ?theme=dark |
w |
Width in pixels | ?w=375 |
h |
Height in pixels | ?h=667 |
bg |
Background color | ?bg=%23f5f5f5 |
Examples:
/#/harness/button-primary
/#/harness/button-primary?theme=dark
/#/harness/button-primary?theme=light&w=320&h=480
/#/harness/card-default?bg=%23000000
Screenshots are saved to the configured directory:
screenshots/
├── button-button-primary-light-default.png
├── button-button-primary-dark-default.png
├── button-button-primary-light-375x667.png
├── button-button-primary-dark-375x667.png
├── button-button-primary-light-1280x800.png
└── button-button-primary-dark-1280x800.png
Naming format: {componentId}-{scenarioId}-{theme}-{viewport}.png
Override viewport per scenario:
{
"id": "button-small-viewport",
"componentId": "button",
"viewport": {
"width": 200,
"height": 100
},
"render": {
"element": "my-button",
"slots": { "default": "Click" }
}
}
Set scenario background:
{
"id": "dark-card",
"componentId": "card",
"background": "#1a1a1a",
"render": {
"element": "my-card"
}
}
name: Visual Tests
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '23'
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps chromium
- name: Run visual tests
run: npx catalogue test
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: |
screenshots/
playwright-report/
For PRs that intentionally change visuals:
- name: Update screenshots
if: contains(github.event.pull_request.labels.*.name, 'update-screenshots')
run: npx catalogue test --update
The catalogue generates a Playwright config at .catalogue-tests/playwright.config.ts. You can extend it by adding a playwright.config.ts at your project root.
// Generated config
export default {
testDir: '.catalogue-tests',
snapshotDir: './screenshots',
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
use: {
baseURL: 'http://localhost:5173',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
],
webServer: {
command: 'npx vite preview --port 5173',
port: 5173,
},
};
Increase timeout in config:
export default {
playwright: {
// Tests might need more time
},
};
npx playwright install chromium