testing-codegen
testing-codegen guides you through snapshot testing with insta and code generation for the Biome codebase. It covers running tests for specific crates, fast iteration with quick-test workflows, and safely managing snapshots—including pruning orphaned files and reviewing changes interactively. Use this skill when testing lint rules, inspecting AST structure, or regenerating parser and analyzer code.
testing-codegen helps you run snapshot tests and manage insta snapshots when developing Biome lint rules.
AI-generated summary based on this skill's SKILL.md
Install
biomejs/biome/testing-codegen · repository language: Rust
git clone https://github.com/biomejs/biome
cp -r biome/.claude/skills/testing-codegen ~/.claude/skills/testing-codegennpx skillfed install biomejs/biome/testing-codegenFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I run snapshot tests in Biome?
testing-codegen helps you execute snapshot tests using insta. Run `cargo test` in the relevant crate to trigger snapshot tests. For faster iteration, use `cargo test quick_test` to run a focused subset. When snapshots differ from expected output, insta prompts you to review and accept or reject changes interactively. This workflow is essential for testing lint rules and validating parser behavior.
What is the Biome insta snapshot testing workflow?
testing-codegen covers the complete insta snapshot cycle in Biome. Write test cases, run `cargo test`, and insta captures actual output as snapshots. Review diffs in your terminal or editor—accept changes with `cargo insta accept` or reject them. For cleanup, use `cargo insta test --unreferenced delete` to prune orphaned snapshot files. This iterative process ensures lint rules, formatters, and analyzers produce correct output.
How can I quickly inspect AST structure and debug parser behavior?
testing-codegen supports rapid AST inspection via the quick-test workflow. Use `cargo test quick_test` to run focused parser tests and examine output. Add the `dbg` macro in test code to print intermediate values. Organize test files in the `specs` folder with clear naming conventions so you can locate and modify parser tests efficiently. This approach accelerates debugging during parser development.
What does the Biome 'just gen-rules' command do?
testing-codegen explains that `just gen-rules` regenerates code for analyzers, formatters, and grammar after you modify rule definitions or parser logic. Run this command to automatically generate updated analyzer implementations and formatter code. Pair it with snapshot testing to validate that generated code produces expected output, ensuring consistency across the codebase.
How should I name and organize test files in Biome?
testing-codegen guides you through Biome's test file structure and naming conventions. Store tests in the `specs` folder with descriptive names that reflect the rule or feature being tested. Include comments in test files to document test-specific options and expected behavior. Follow the convention of grouping valid and invalid test cases together, making it easy for the test runner to validate both passing and failing scenarios.
How do I manage and prune orphaned snapshot files?
testing-codegen covers snapshot maintenance with insta. After refactoring or removing tests, orphaned snapshot files may remain. Run `cargo insta test --unreferenced delete` to automatically identify and remove snapshots no longer referenced by active tests. This keeps your snapshot directory clean and prevents confusion during code review. Always review the list of files to be deleted before confirming.
SKILL.md
rendered from the published skill — quoted content, verbatim
Purpose
Use this skill for testing and code generation. Covers snapshot testing with
insta and code generation commands.
Prerequisites
- Install required tools:
just install-tools(installscargo-insta) - Install pnpm:
curl -fsSL https://get.pnpm.io/install.sh | sh -in repo root - Understand which changes require code generation
Common Workflows
Run Tests
# Run all tests
cargo test
# Run tests for specific crate
cd crates/biome_js_analyze
cargo test
# Run specific test
cargo test quick_test
# Show test output (for dbg! macros)
cargo test quick_test -- --show-output
# Run tests with just (uses CI test runner)
just test
# Test specific crate with just
just test-crate biome_cli
Quick Test for Rules
Fast iteration during development:
```rust // In
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
.claude/skills/testing-codegen/SKILL.md