Skip to content

feat: Add insta snapshot tests for formatter - #64

Closed
sorafujitani wants to merge 2 commits into
mainfrom
feat/insta-snapshot-tests
Closed

sorafujitani wants to merge 2 commits into
mainfrom
feat/insta-snapshot-tests

Conversation

@sorafujitani

@sorafujitani sorafujitani commented Jan 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add snapshot tests for the formatter using Rust's insta crate.
  • Make formatter output easy to inspect visually.
  • Make formatting regressions easier to detect.

Test Cases

The snapshots cover formatter output for the following Ruby constructs:

  • Class definitions, with and without inheritance
  • Module definitions
  • Method definitions, with and without parameters
  • if conditional statements
  • case/when expressions
  • while loops

The tests parse Ruby source with the native Prism adapter and verify the output from the current Formatter pipeline.

How to Run

# Run the snapshot tests
cargo test snapshot_

# Review and accept updated snapshots
cargo insta review

How to Add New Tests

  1. Add a test to ext/rfmt/tests/formatter_snapshots.rs.
  2. Run cargo test to generate a new .snap.new file.
  3. Review and accept the result with cargo insta review.

Closes #63

sorafujitani and others added 2 commits January 15, 2026 17:46
Introduces snapshot testing using the insta crate to verify formatter
output consistency. This provides visual regression testing for the
Emitter's Ruby code formatting capabilities.

Test cases cover:
- Basic class/module formatting
- Method definitions (with and without parameters)
- Conditional statements (if)
- Case/when expressions
- While loops

The snapshot tests use JSON AST input and source code to validate
the formatter output, enabling easy detection of formatting regressions.

Closes #63

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

feat: Add insta snapshot tests for formatter

1 participant