Screenshot HTML Mockups
Automate taking screenshots of HTML mockups using Puppeteer from a centralized runner location.
Usage
code
/screenshot [folder/file]
Mockups Location
Default location: ProductSpecification/stories/*/mockups/
Workflow
Phase 1: Determine Scope
Parse user input to determine target:
Folder/file filtering:
- •
/screenshot— All mockups in default location - •
/screenshot login.html— Single file - •
/screenshot 01_auth— Files matching pattern
Phase 2: Ensure Puppeteer Environment
The centralized Puppeteer runner is in .screenshots-temp/:
- •Check if
.screenshots-temp/node_modulesexists:- •If not: run
cd .screenshots-temp && npm install
- •If not: run
- •This only needs to happen once, not per-mockup-directory
Phase 3: Run Screenshot Script
Execute from the centralized location:
bash
cd .screenshots-temp && node take-screenshots.js [target]
Examples:
bash
# All mockups in default directory cd .screenshots-temp && node take-screenshots.js # Specific file (relative to repo root) cd .screenshots-temp && node take-screenshots.js ../ProductSpecification/stories/01-login-logout/mockups/desktop/login.html # Directory with HTML files cd .screenshots-temp && node take-screenshots.js ../ProductSpecification/stories/01-login-logout/mockups/desktop/ # Filter by filename pattern cd .screenshots-temp && node take-screenshots.js ../ProductSpecification/stories/01-login-logout/mockups/ mobile
Phase 4: Output Summary
Report to user:
- •Number of screenshots taken
- •Output location (screenshots saved alongside HTML files or in
screenshots/subfolder) - •Any failures encountered
Example Invocations
code
/screenshot # All mockups /screenshot login.html # Specific file /screenshot mobile # Files containing "mobile"
Design Constraints
- •Mobile detection: Files with
mobilein filename use mobile viewport (390x844) - •Desktop viewport: 1400x900
- •Element selector: Crop to
.mockup-cardelement when present - •Fallback: Full page screenshot if
.mockup-cardnot found - •Format: PNG
- •Output:
screenshots/subfolder in the mockups directory - •Skip:
node_modules/andscreenshots/directories
Notes
- •Puppeteer is pre-installed in
.screenshots-temp/ - •No npm installation needed in mockup directories
- •Screenshots are deterministic for visual regression testing
- •Re-running overwrites existing screenshots