Merged
Conversation
…a snapshot` CLI Introduce file-based snapshot testing: `karva.assert_snapshot(value)` compares values against stored `.snap` files, with `--snapshot-update` to accept changes and `karva snapshot accept/reject/pending/review` for managing pending snapshots. Key implementation details: - New `karva_snapshot` crate for snapshot storage, formatting, and diffing - Snapshot names sanitize `::` to `__` for Windows filesystem compatibility - `--snapshot-update` forwarded as CLI arg to workers (no unsafe set_var in main binary) - Snapshot attrs set on karva module with warning logging on failure - Rename test helpers: `command()` → `test()`, `command_no_parallel()` → `test_no_parallel()`
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
- Fix doubled module prefix in snapshot names by using function_name() instead of qualified_test_name for snapshot context - Add colored diff output (red deletions, green insertions) - Indent continuation lines in multi-line diagnostic error messages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the `expression` field from snapshot files since it was hardcoded and not useful. Add line numbers to the `source` field using `sys._getframe(0).f_lineno` (e.g. `test.py:5::test_hello`). Rewrite diff output to use insta-style formatting with box-drawing characters, dual line numbers, and colored headers. Add integration tests for the `karva snapshot review` command covering accept, reject, skip, and no-pending flows.
Widen line number columns from 4 to 5 chars so the `│` separator aligns with `┬`/`┴` in border lines (both now at column 12). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rewrite diff rendering with context-aware grouping (grouped_ops), word-level inline emphasis, and adaptive terminal width. Add insta-style interactive review menu with colored keys, info/diff toggle actions, skip-all support, and categorized summary output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 20 new integration tests covering multiline content, whitespace handling, unicode, special characters, YAML-like content, empty strings, multiple files, named snapshots, parametrized+named combinations, update overwrites, mixed test results, multiline diffs, batch accept/reject/pending, and review actions (accept-all, reject-all, mixed). Also fix test_print_changeset to match the pipe separator change in diff output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover assert_snapshot() usage, formats (str/repr/json), named snapshots, snapshot file format, --snapshot-update flag, CLI commands (accept, reject, pending, review), and parametrized test integration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
karva.assert_snapshot(value)API for file-based snapshot testing with support for named snapshots, multiple formats (str/repr/json), and parametrized testskarva snapshotCLI withaccept,reject,pending, andreviewsubcommands for managing pending snapshotskarva_snapshotcrate handling snapshot storage, formatting, and diffing::to__in snapshot filenames for Windows filesystem compatibility--snapshot-updateas CLI arg to workers instead of usingunsafe set_varin main binarysetattrfailures instead of silently discarding errorscommand()→test(),command_no_parallel()→test_no_parallel(), addsnapshot()methodTest plan
just test)prek run -a)unsafecode in main binary (karva/src/lib.rs)::in snapshot filesystem paths🤖 Generated with Claude Code