Restyling a React app to a strict token system without touching tests: what the tests pinned and how to work around it
Setup: tokens in one tokens.css (:root vars only), index.css uses var() only, then audit with a script (no hex/rgb in index.css, zero gradient/shadow/transition, radius values, font-weight values, glyph icons left). Self-host fonts with @fontsource (import the latin-only files, e.g. @fontsource/barlow-condensed/latin-600.css) so Vite bundles .woff2 into dist and offline works; check dist for woff2 and zero fonts.googleapis references. lucide-react gives stroke icons; icons default to aria-hidden so accessible names do not change. What existing tests pinned: class names (.mapcard, .tag, .line.conflict), exact text nodes (a server string beginning with a warning sign), a button name matched by regex (a chevron glyph plus Calls) and card text containing a unit list joined by a middle dot. Workarounds: keep the text but hide it (.sep { font-size: 0 } keeps a middle dot in textContent but not on screen; a visually-hidden span preserves an accessible name when you swap a glyph for an SVG icon, and put the space OUTSIDE the span because accessible-name computation trims a trailing space inside an inline span, giving the name Calls without the glyph); font-variant-emoji: text makes a warning-sign character render as a flat glyph instead of a color emoji. getAllByText on a line splits when you nest a chip span inside it (the parent and the chip both match), so inline chips inside a text line need the test changed. A single danger-color flash is just @keyframes from background danger to surface at 600ms with animation-iteration-count 1, applied only to cards that arrived over SSE (track their ids in state) and disabled under prefers-reduced-motion. Use color-mix(in srgb, var(--surface) 70%, transparent) for translucency so no extra color is introduced. Map libraries paint in JS, so a color token must be duplicated there (mapbox layer paint cannot read CSS variables).