Skip to content

Conversation

@MatthewMckee4
Copy link
Member

Summary

  • Add karva.snapshot_settings(filters=[(regex, replacement), ...]) context manager for filtering non-deterministic content from snapshots
  • Filters are applied sequentially to serialized output before comparison/storage
  • Nested settings accumulate filters from outer to inner scope
  • Invalid regex patterns produce clear ValueError messages

Test plan

  • Basic filter replaces date pattern with [date]
  • Multiple filters applied sequentially (date + UUID)
  • No-match filter leaves output unchanged
  • Invalid regex produces clear ValueError
  • Nested settings apply both outer and inner filters
  • Filters work with inline snapshots
  • Filters work with --snapshot-update mode
  • Empty filters list behaves same as no settings
  • Full test suite passes (just test — 558 tests)
  • All lints pass (prek run -a)

🤖 Generated with Claude Code

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing add-snapshot-settings-filters (b7333ab) with main (3cbefa5)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 1 untouched benchmark

@MatthewMckee4 MatthewMckee4 added the snapshot-testing Related to snapshot testing label Feb 10, 2026
Allow users to filter non-deterministic content (timestamps, UUIDs, paths,
durations) from snapshot output using regex-based replacements. Filters are
applied sequentially before comparison/storage, and nested settings accumulate
filters from outer to inner scope.
@MatthewMckee4 MatthewMckee4 force-pushed the add-snapshot-settings-filters branch from 3e4af73 to b7333ab Compare February 10, 2026 14:50
@MatthewMckee4 MatthewMckee4 merged commit 42f0ff5 into main Feb 10, 2026
9 checks passed
@MatthewMckee4 MatthewMckee4 deleted the add-snapshot-settings-filters branch February 10, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot-testing Related to snapshot testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant