Goal
Create a reusable scrubber utility that strips superficial/noisy attributes from rendered HTML before snapshot comparison.
Context
Parent: #119 (Frontend approval/snapshot testing infrastructure)
When snapshot-testing rendered Svelte components, these change across runs without meaningful differences:
- Svelte scoped class hashes (
svelte-1a2b3c)
- Dynamic
id attributes
- Tailwind class ordering (if purgeable classes shift)
- Timestamps, UUIDs, random tokens
Tasks
Acceptance Criteria
- Scrubber removes Svelte scoped classes, dynamic IDs, timestamps, UUIDs
- Scrubber preserves semantic attributes (
aria-*, data-testid, role, etc.)
- Configurable: callers can opt-in/out of specific scrubbers
- Tests pass, zero dependencies beyond Vitest
Usage Pattern
import { scrubHtml } from '$tests/helpers/scrub-snapshot'
import { render } from '@testing-library/svelte'
it('renders correctly', () => {
const { container } = render(MyComponent)
await expect(scrubHtml(container.innerHTML)).toMatchFileSnapshot('./__snapshots__/my-component.html')
})
Goal
Create a reusable scrubber utility that strips superficial/noisy attributes from rendered HTML before snapshot comparison.
Context
Parent: #119 (Frontend approval/snapshot testing infrastructure)
When snapshot-testing rendered Svelte components, these change across runs without meaningful differences:
svelte-1a2b3c)idattributesTasks
tests/helpers/scrub-snapshot.tswith composable scrubber functions/class="[^"]*svelte-[a-z0-9]+[^"]*"/)/id="[^"]*"/— configurable allowlist)scrubHtml(html: string, options?: ScrubOptions)default pipelinetoMatchFileSnapshotAcceptance Criteria
aria-*,data-testid,role, etc.)Usage Pattern