• Docs
  • Components
  • Blocks
  • Admin
CtrlK
Get Started
  • Introduction
  • Setup
  • CLI
  • VS Code Extension
  • Figma Code Connect
  • MCP Server
  • llms.txt
  • Changelog
Foundations
  • Design Tokens
  • Theming & Modes
  • Semantic Colors
  • Spacing
  • Typography
Testing
  • Test Guide
  • Performance Tests
  • Visual Regression
Components
  • Accordion
  • Activity Feed
  • Alert
  • Avatar
  • Badge
  • Breadcrumbs
  • Button
  • Card
  • Carousel
  • Checkbox
  • Collapsible
  • Combobox
  • Command Palette
  • Context Menu
  • Date Picker
  • Dialog
  • Dropdown Menu
  • File Upload
  • Hover Card
  • Input
  • Kbd
  • Label
  • Menubar
  • Metric Card
  • Multi Select
  • Navigation Menu
  • Pagination
  • Popover
  • Progress
  • Quick Actions
  • Radio
  • Rating
  • Resizable
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Skeleton
  • Slider
  • Spinner
  • Split Button
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Textarea
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree View
Blocks
  • Activity Feed
  • App Shell
  • Authentication Block
  • Benefits Section
  • Cta Section
  • Data Table
  • Empty State
  • Faq Section
  • Feature Grid Section
  • Footer Section
  • Hero Section
  • Kpi Dashboard
  • Kpi Strip
  • Link Card
  • Metric Card
  • Navigation Header
  • Pagination Footer
  • Pricing Table
  • Quick Actions
  • Settings Screen
Resources
  • API Reference
TypographyPerformance Tests

Test Guide

The project includes these test types:

๐Ÿ“‹ Test types

The project includes these test types:

  1. A11y Tests โ€“ Accessibility checks (38 components)
  2. Unit Tests โ€“ Component unit tests
  3. Performance Tests โ€“ Lighthouse CI
  4. Visual Regression Tests โ€“ Chromatic
  5. Bundle Size Tests โ€“ Bundle size analysis

๐Ÿš€ Quick start โ€“ run everything

# Run all tests
pnpm test
# Run all tests + build
pnpm test && pnpm build
# Full verification (tests + build + bundle analysis)
pnpm test && pnpm build && pnpm bundle:analyze

โ™ฟ A11y Tests

Accessibility tests use vitest-axe and axe-core to check WCAG 2.1 compliance.

How to run

# A11y tests for all components
pnpm test:a11y
# A11y tests for a specific file
pnpm test packages/ui/src/a11y.test.tsx

Location

packages/ui/src/a11y.test.tsx

Coverage

A11y tests cover 38 components:

  • All core UI components
  • Form components
  • Navigation components
  • Feedback components

๐Ÿงช Unit Tests

Unit tests use Vitest and React Testing Library.

How to run

# All unit tests
pnpm test
# Watch mode
pnpm test:watch
# With coverage
pnpm test:coverage

Location

Unit tests live in *.test.tsx files next to components.

โšก Performance Tests

Performance tests use Lighthouse CI to monitor Core Web Vitals and enforce budgets.

How to run

# Run Lighthouse CI locally
pnpm --filter @fragment_ui/www start &
lhci autorun
# Check bundle size
pnpm bundle:analyze

Configuration

Lighthouse CI config:

lighthouserc.js

Performance budgets

  • First Contentful Paint (FCP): < 1.8s
  • Largest Contentful Paint (LCP): < 2.5s
  • Time to Interactive (TTI): < 3.8s
  • Total Blocking Time (TBT): < 200ms
  • Cumulative Layout Shift (CLS): < 0.1

๐ŸŽจ Visual Regression Tests

Visual tests use Chromatic to compare component screenshots.

How to run

# Run Storybook and Chromatic
pnpm storybook
npx chromatic --project-token=YOUR_TOKEN
# In CI/CD Chromatic runs automatically (GitHub Actions)

Configuration

Chromatic config: packages/ui/.storybook/preview.ts and .github/workflows/chromatic.yml.

Features

  • Multiple viewports (mobile, tablet, desktop)
  • Multiple themes (light, dark)
  • Automatic visual diffing
  • Review changes before merge

๐Ÿ“ฆ Bundle Size Tests

Bundle analysis checks component sizes and limits.

How to run

# Bundle size analysis
pnpm bundle:analyze
# Check limits
pnpm bundle:check

Limits

  • Max component size: 50KB (source)
  • Max gzipped: 15KB
  • Alert threshold: 80% of limit

๐Ÿ”„ CI/CD Integration

All tests run automatically in GitHub Actions.

Workflow files

  • .github/workflows/ci.yml โ€“ Unit tests, build, bundle size
  • .github/workflows/performance.yml โ€“ Lighthouse CI
  • .github/workflows/chromatic.yml โ€“ Visual regression tests

When they run

  • Push to main: all tests
  • Pull Request: unit tests, build, bundle size
  • Merge to main: performance tests, Chromatic

๐Ÿ“ Best Practices

  • Before commit: run pnpm test locally
  • Before PR: run all tests and check bundle size
  • After visual changes: review Chromatic results
  • After performance changes: check Lighthouse CI
  • When adding components: add A11y and unit tests

๐Ÿ› Troubleshooting

A11y tests failing

  • Verify ARIA attributes
  • Ensure all interactive elements are keyboard accessible
  • Check color contrast

Performance tests failing

  • Check bundle size limits
  • Optimize heavy components (code splitting, lazy loading)
  • Remove unnecessary dependencies

Visual regression tests failing

  • Verify if changes are intentional
  • If yes, accept updates in Chromatic
  • Confirm viewport and theme are correct

๐Ÿ”— Links

  • Visual Regression Testing
  • Performance Tests
  • GitHub Actions
TypographyPerformance Tests