Skip to content

feat: Add insta snapshot tests for formatter#64

Open
fs0414 wants to merge 1 commit intomainfrom
feat/insta-snapshot-tests
Open

feat: Add insta snapshot tests for formatter#64
fs0414 wants to merge 1 commit intomainfrom
feat/insta-snapshot-tests

Conversation

@fs0414
Copy link
Owner

@fs0414 fs0414 commented Jan 15, 2026

Summary

  • Rustのinsta crateを使用してformatterのsnapshot testを実装
  • Emitterの出力を視覚的に検証可能に
  • リグレッションの検出が容易に

Test Cases

以下のRuby構文のフォーマット結果をsnapshotとして記録:

  • クラス定義(継承あり/なし)
  • モジュール定義
  • メソッド定義(パラメータあり/なし)
  • 条件分岐(if)
  • case/when文
  • whileループ

How to Run

# snapshot testを実行
cargo test snapshot_

# 新しいsnapshotを確認・承認
cargo insta review

How to Add New Tests

  1. ext/rfmt/src/emitter/mod.rssnapshot_testsモジュールにテストを追加
  2. cargo testを実行(新しい.snap.newファイルが生成される)
  3. cargo insta reviewで内容を確認・承認

Closes #63

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