Skip to content

Conversation

@MatthewMckee4
Copy link
Member

Summary

  • Fix base_function_name multi-digit inline line numbers: strip_suffix(|c| c.is_ascii_digit()) only strips one trailing digit, so test_foo_inline_15test_foo_inline_1 instead of test_foo. Replaced with trim_end_matches to strip all trailing digits. This fixes prune/unreferenced detection for inline snapshots on lines >= 10.
  • Fix find_inline_argument for assert_json_snapshot: The hardcoded "assert_snapshot(" pattern didn't match assert_json_snapshot( calls, so inline snapshots with JSON couldn't be updated or accepted. Now tries both patterns and picks the closest match.
  • Fix review summary text: Changed "insta review finished""review finished".
  • Add 5 unit tests: multi-digit inline line numbers, JSON snapshot inline finding, format roundtrip with --- content, and malformed parse inputs.
  • Add 8 integration tests: JSON inline create/accept/named, named accept/reject, counter gaps with mixed named/unnamed snapshots, inline with backslashes and double quotes.

Test plan

  • cargo nextest run -p karva_snapshot — all 65 unit tests pass
  • just test — all 593 tests pass
  • prek run -a — all pre-commit checks pass

- Fix `base_function_name` to handle multi-digit inline line numbers by
  using `trim_end_matches` instead of `strip_suffix` which only strips
  one trailing digit
- Fix `find_inline_argument` to match `assert_json_snapshot(` calls in
  addition to `assert_snapshot(`, enabling inline update/accept for JSON
  snapshots
- Fix review summary to say "review finished" instead of "insta review
  finished"
- Add unit tests for format.rs (roundtrip with dashes, malformed input)
- Add integration tests for JSON inline create/accept/named, named
  accept/reject, counter gaps with mixed named/unnamed, and inline
  snapshots with backslashes and quotes
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2026

Merging this PR will not alter performance

⚠️ 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.

✅ 1 untouched benchmark


Comparing fix/snapshot-bugs-and-edge-case-tests (4bde6a7) with main (bcab060)

Open in CodSpeed

Multiple unnamed `assert_snapshot()` calls in a single test now raise an
error instead of silently auto-numbering. Users must either provide
explicit `name=` parameters or opt in via
`snapshot_settings(allow_duplicates=True)`.

Named snapshots no longer consume the unnamed counter, eliminating
numbering gaps (e.g. unnamed→named→unnamed now produces `-2` not `-3`).

Also fixes `test_inline_snapshot_with_backslash` to use
`insta::assert_snapshot!` instead of `assert!(source.contains(...))`.
When `allow_duplicates` is active, unnamed snapshots now get `-0`, `-1`,
`-2` suffixes instead of bare name, `-2`, `-3`. This makes the numbering
unambiguous and sequential. Single unnamed snapshots (without
`allow_duplicates`) keep the bare test name with no suffix.
@MatthewMckee4 MatthewMckee4 merged commit febcd92 into main Feb 10, 2026
8 checks passed
@MatthewMckee4 MatthewMckee4 deleted the fix/snapshot-bugs-and-edge-case-tests branch February 10, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant