User Interface

Theme Regression Testing Strategy

A complete testing strategy for theme correctness across stores, CSS tokens, accessibility, and first paint behavior.

Theme Regression Testing Strategy

Scope

A layered approach to prevent dark and light mode regressions in production.

Pyramid

  • unit: resolution logic and store behavior
  • integration: layout application and CSS token usage
  • e2e: paint, navigation, and persistence

Unit Cases

  • preference precedence matrix
  • storage normalization
  • media query listener transitions

Integration Cases

  • data-theme updates on state changes
  • key screens inherit semantic tokens correctly
  • contrast utility reports no AA violations

E2E Cases

  • first paint is in resolved theme
  • no flash when navigating between routes
  • multi-tab storage sync works

Tooling

  • vitest for store and utility tests
  • playwright for visual and behavior checks
  • contrast validator in CI gate

Release Gate

Do not ship when:

  • any critical theme test fails
  • contrast checks fail
  • first-paint mismatch detected in smoke tests

Anti-patterns

  • relying only on manual QA
  • snapshot tests without behavior assertions
  • missing tests for system theme changes