Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
Test visual appearance automatically
Catch CSS regressions early
Verify cross-browser compatibility
Test responsive designs
Prevent visual bugs in production
Essential for quality assurance
Compare screenshots to detect changes
Percy, BackstopJS, ChromaticTest in multiple browsers
BrowserStack, Sauce LabsTest different screen sizes
Chrome DevTools, LambdaTestTest contrast, focus, readability
axe, LighthouseTakes screenshots of your site, compares them to baseline images, and alerts you to any visual differences. Perfect for catching CSS bugs that break layouts!
1. Baseline
Take screenshot of correct design
2. Compare
Run after code changes
3. Review
Approve or fix differences
Popular visual testing platform. Integrates with CI/CD. Free for open source.
percy.ioFree, open-source visual regression testing. Runs locally or in CI.
npm install -g backstopjsMade by Storybook team. Great for component testing. Free tier available.
chromatic.com# Install BackstopJS
npm install -g backstopjs
# Initialize in your project
backstop init
# Edit backstop.json to define test scenarios
{
"scenarios": [
{
"label": "Homepage",
"url": "http://localhost:3000",
"selectors": ["body"]
},
{
"label": "Button Component",
"url": "http://localhost:3000/components",
"selectors": [".button"]
}
],
"viewports": [
{ "label": "phone", "width": 375, "height": 667 },
{ "label": "tablet", "width": 768, "height": 1024 },
{ "label": "desktop", "width": 1920, "height": 1080 }
]
}
# Create baseline (reference) screenshots
backstop reference
# Run tests (compare to baseline)
backstop test
# View results in browser
# Approve changes if they're intentional
backstop approveBrowserStack
Test in 3000+ real browsers and devices. Live interactive testing. Screenshots & videos.
browserstack.com - Free trial availableLambdaTest
Cloud-based testing. Automated screenshots. Integrates with CI/CD.
lambdatest.com - Free tier availableSauce Labs
Enterprise testing platform. Supports Selenium and Cypress. CI/CD integration.
saucelabs.comInstall multiple browsers on your machine and test manually:
Chrome
google.com/chrome
Firefox
mozilla.org/firefox
Safari
Mac/iOS only
Edge
microsoft.com/edge
Chrome (and other browsers) have built-in responsive testing tools. Free and powerful!
# Test these breakpoints at minimum:
✓ Mobile (320px - 480px)
- Check menu collapses to hamburger
- Text is readable
- Images scale properly
- No horizontal scroll
✓ Tablet (481px - 768px)
- Layout adjusts appropriately
- Touch targets are large enough (44x44px min)
- Navigation works
✓ Desktop (769px - 1920px)
- Full layout displays correctly
- Hover states work
- Multi-column layouts function
✓ Large Desktop (1921px+)
- Content doesn't stretch too wide
- Max-width containers work
- No awkward spacing// Install Playwright
npm install -D @playwright/test
// tests/css-tests.spec.js
import { test, expect } from '@playwright/test';
test('button has correct styles', async ({ page }) => {
await page.goto('http://localhost:3000');
const button = page.locator('.button');
// Test computed styles
await expect(button).toHaveCSS('background-color', 'rgb(59, 130, 246)');
await expect(button).toHaveCSS('padding', '12px 24px');
await expect(button).toHaveCSS('border-radius', '6px');
// Test hover state
await button.hover();
await expect(button).toHaveCSS('background-color', 'rgb(37, 99, 235)');
});
test('layout is responsive', async ({ page }) => {
// Test mobile
await page.setViewportSize({ width: 375, height: 667 });
await page.goto('http://localhost:3000');
const menu = page.locator('.menu');
await expect(menu).toHaveCSS('display', 'none'); // Hidden on mobile
// Test desktop
await page.setViewportSize({ width: 1920, height: 1080 });
await expect(menu).toHaveCSS('display', 'flex'); // Visible on desktop
});
test('take screenshot for visual regression', async ({ page }) => {
await page.goto('http://localhost:3000');
// Take full page screenshot
await page.screenshot({ path: 'screenshots/homepage.png', fullPage: true });
// Compare to baseline (requires setup)
await expect(page).toHaveScreenshot('homepage.png');
});# Run tests
npx playwright test
# Run in headed mode (see browser)
npx playwright test --headed
# Run specific test file
npx playwright test css-tests.spec.js
# Update baseline screenshots
npx playwright test --update-snapshotsCatch issues before users see them
Ensure nothing broke during changes
Test component library changes
New browser versions may break CSS
Visual Regression: BackstopJS (free), Percy, Chromatic
Cross-Browser: BrowserStack, LambdaTest, Sauce Labs
Responsive: Chrome DevTools (free), BrowserStack
E2E with CSS: Playwright, Cypress
Accessibility: axe DevTools, Lighthouse