Skip to content

test: adopt insta snapshot testing - #162

Merged
Shinigami92 merged 1 commit into
mainfrom
test-insta-snapshots
Jun 16, 2026
Merged

Shinigami92 merged 1 commit into
mainfrom
test-insta-snapshots

Conversation

@Shinigami92

@Shinigami92 Shinigami92 commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Documentation

    • Added snapshot testing guidance to contribution guidelines, including when to use snapshots and how to review changes.
  • Tests

    • Migrated test assertions to snapshot testing across multiple test suites for improved maintainability and clearer test comparisons.

@Shinigami92 Shinigami92 self-assigned this Jun 16, 2026
@Shinigami92 Shinigami92 added the c: chore PR that doesn't affect the runtime behavior label Jun 16, 2026
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63566f06-04a9-4df0-b85e-fd643431f985

📥 Commits

Reviewing files that changed from the base of the PR and between 47a9cde and 44080e4.

⛔ Files ignored due to path filters (17)
  • Cargo.lock is excluded by !**/*.lock
  • src/diagnostic/format/tests/snapshots/hsml__diagnostic__format__tests__default__it_should_format_error_without_code.snap is excluded by !**/*.snap
  • src/diagnostic/format/tests/snapshots/hsml__diagnostic__format__tests__default__it_should_format_warning.snap is excluded by !**/*.snap
  • src/diagnostic/format/tests/snapshots/hsml__diagnostic__format__tests__default__it_should_format_warning_with_source_context.snap is excluded by !**/*.snap
  • src/diagnostic/format/tests/snapshots/hsml__diagnostic__format__tests__default__it_should_underline_span_range.snap is excluded by !**/*.snap
  • src/diagnostic/format/tests/snapshots/hsml__diagnostic__format__tests__gitlab__it_should_format_error_as_major_severity.snap is excluded by !**/*.snap
  • src/diagnostic/format/tests/snapshots/hsml__diagnostic__format__tests__gitlab__it_should_format_warning_as_codeclimate_issue.snap is excluded by !**/*.snap
  • src/parser/attribute/tests/snapshots/hsml__parser__attribute__tests__node__it_should_return_attribute_nodes_with_dev_comments.snap is excluded by !**/*.snap
  • src/parser/tag/tests/snapshots/hsml__parser__tag__tests__node__it_should_return_tag_node_with_piped_text.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_compile_parsed_content.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_compile_parsed_content_2.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_compile_parsed_elk_main_content_component.snap is excluded by !**/*.snap
  • tests/snapshots/compiler__it_should_compile_parsed_elk_status_content_component.snap is excluded by !**/*.snap
  • tests/snapshots/parse__it_should_parse.snap is excluded by !**/*.snap
  • tests/snapshots/parse__it_should_parse_tag_with_multiple_ids.snap is excluded by !**/*.snap
  • tests/snapshots/parse__it_should_parse_with_comments.snap is excluded by !**/*.snap
  • tests/snapshots/parse__it_should_parse_wrapped_attributes.snap is excluded by !**/*.snap
📒 Files selected for processing (8)
  • CONTRIBUTING.md
  • Cargo.toml
  • src/diagnostic/format/tests/default.rs
  • src/diagnostic/format/tests/gitlab.rs
  • src/parser/attribute/tests/node.rs
  • src/parser/tag/tests/node.rs
  • tests/compiler.rs
  • tests/parse.rs

📝 Walkthrough

Walkthrough

Adds insta as a pinned dev-dependency with json and redactions features, documents the snapshot workflow in CONTRIBUTING.md, and replaces hardcoded inline expected strings and AST structures across diagnostic formatter tests, parser unit tests, and compiler/parse integration tests with insta snapshot assertions. Location fields are redacted via insta filters where applicable.

Changes

insta Snapshot Migration

Layer / File(s) Summary
insta dependency and snapshot workflow docs
Cargo.toml, CONTRIBUTING.md
Pins insta (with json and redactions features) as a dev-dependency and adds a CONTRIBUTING.md subsection documenting when snapshots are used and the cargo insta review/accept commands.
Diagnostic formatter tests migrated to snapshots
src/diagnostic/format/tests/default.rs, src/diagnostic/format/tests/gitlab.rs
Replaces hardcoded expected strings in four default.rs formatter tests with insta::assert_snapshot!(output), and removes explicit JSON field assertions in two gitlab.rs tests in favor of insta::assert_json_snapshot!(parsed).
Parser unit tests migrated to JSON snapshots
src/parser/attribute/tests/node.rs, src/parser/tag/tests/node.rs
Removes now-unused CommentNode, ClassNode, and TextNode imports, and replaces deep structural assert_eq! comparisons with insta::assert_json_snapshot! calls that redact .location fields.
Compiler and parse integration tests migrated to snapshots
tests/parse.rs, tests/compiler.rs
Introduces an assert_ast_snapshot! macro in tests/parse.rs for location-redacted AST JSON snapshots, applies it to four parse tests, and replaces four inline HTML assert_eq! calls in tests/compiler.rs with insta::assert_snapshot!.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop hop, no more walls of string to compare,
The snapshots now live in their own cozy lair.
cargo insta review — a quick little dash,
Locations redacted with one tiny splash.
Less inline clutter, more room to play,
The rabbit says: snapshot the assertions away! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: adopt insta snapshot testing' clearly and concisely summarizes the main change—replacing traditional assertions with insta snapshot testing across multiple test files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-insta-snapshots

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Shinigami92
Shinigami92 marked this pull request as ready for review June 16, 2026 09:50
@Shinigami92
Shinigami92 added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit e4141a6 Jun 16, 2026
10 checks passed
@Shinigami92
Shinigami92 deleted the test-insta-snapshots branch June 16, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: chore PR that doesn't affect the runtime behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant