# Insta Snapshots > Guía para trabajar con y actualizar los tests de snapshot de insta en Oxc sin necesitar interacción con la terminal. Fuente: https://skillsagentes.com/skills/oxc-project/oxc/insta-snapshots Markdown: https://skillsagentes.com/skills/oxc-project/oxc/insta-snapshots.md Repositorio: https://github.com/oxc-project/oxc Autor: oxc-project Licencia: MIT Actualizado: hace 6 meses Coste de contexto: 23 tok instalada, 971 tok al activarse, 971 tok con todos los archivos del bundle Bundle: 1 archivo, 4 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add oxc-project/oxc --skill insta-snapshots --agent claude-code # Cursor npx -y skills add oxc-project/oxc --skill insta-snapshots --agent cursor # Codex npx -y skills add oxc-project/oxc --skill insta-snapshots --agent codex # Gemini CLI npx -y skills add oxc-project/oxc --skill insta-snapshots --agent gemini # Windsurf npx -y skills add oxc-project/oxc --skill insta-snapshots --agent windsurf # Cline npx -y skills add oxc-project/oxc --skill insta-snapshots --agent cline ``` ## Qué hace - Lista y revisa snapshots pendientes (.snap.new) de insta sin usar la UI interactiva 'cargo insta review' - Acepta o rechaza snapshots específicos o de todo el workspace con 'cargo insta accept/reject' - Verifica los cambios aceptados con 'git diff' sobre los archivos .snap ## Cuándo usarla - Los tests fallan por un desajuste de snapshot - Se cambió código que afecta las salidas esperadas de los tests de insta ## Cuándo no - Los archivos son .snap.md de Vitest (no son de Insta y este skill no los cubre) ## Qué la activa - "Revisa los snapshots pendientes de insta y acéptalos si son correctos" - "Genera y revisa los nuevos snapshots del linter de Oxc" - "Rechaza todos los snapshots pendientes del workspace" ## Antes de instalar - Requiere cargo insta instalado en el proyecto Oxc. - Necesita en el PATH: git ## Archivos - SKILL.md — 4 KB ## SKILL.md Reproducido tal cual desde oxc-project/oxc bajo MIT. Esta sección es el documento original y está en inglés. This skill guides you through working with [insta](https://insta.rs) snapshot tests in the Oxc codebase without requiring terminal interaction. ## What are Insta Snapshots? Insta is a snapshot testing library for Rust. Oxc uses it extensively for: - Linter rule tests (`crates/oxc_linter/src/snapshots/`) - Semantic analysis tests (`crates/oxc_semantic/tests/integration/snapshots/`) - Other crate-specific snapshot tests Snapshots track **expected test outputs** (often failures or errors). When code changes, new snapshots are generated as `.snap.new` files for review. ## Running Tests and Generating Snapshots ### Run tests for a specific crate: ```bash cargo test -p ``` This generates `.snap.new` files if test outputs have changed. ## Reviewing Snapshots Non-Interactively **IMPORTANT**: Avoid using `cargo insta review` (the interactive terminal UI). Instead, follow these steps: ### 1. List all pending snapshots ```bash cargo insta pending-snapshots # Or for workspace-wide: cargo insta pending-snapshots --workspace ``` This shows all `.snap.new` files waiting for review. ### 2. Read the snapshot files directly New snapshots are stored as `.snap.new` files next to their corresponding `.snap` files. You can use `cargo insta pending-snapshots` to view the changes to the snapshot files. ### 3. Accept or reject changes **Accept all pending snapshots:** ```bash cargo insta accept # Or workspace-wide: cargo insta accept --workspace ``` **Accept specific snapshot(s):** ```bash cargo insta accept --snapshot ``` **Reject all pending snapshots:** ```bash cargo insta reject # Or workspace-wide: cargo insta reject --workspace ``` This deletes all `.snap.new` files. ### 4. Verify the changes After accepting, the `.snap.new` files become `.snap` files. Check with git: ```bash git diff ``` ## Common Workflows ### After fixing a bug or adding new snapshot tests: 1. Run tests: `cargo test -p oxc_linter` (or relevant crate) 2. Check pending: `cargo insta pending-snapshots` 3. Read new snapshots to verify they match expected behavior 4. Accept if correct: `cargo insta accept` 5. Commit the updated `.snap` files ### Working with specific test files: 1. Run: `cargo test -p oxc_linter specific_test_name` 2. Read: `cargo insta pending-snapshots` - look for `specific_test_name.snap.new` 3. Accept: `cargo insta accept -p oxc_linter` ## Snapshot File Formats - `.snap` - Current expected output - `.snap.new` - New output from recent test run (pending review), do not commit if these files are present Note that `.snap.md` files are from Vitest, and **not** Insta. They are used in conformance tests, and are not handled by the instructions in this skill. ## Tips - **Always review snapshots manually** before accepting - don't blindly accept all changes - Snapshot files are **checked into git** - they're part of the test suite - Large snapshot changes may indicate breaking changes or bugs - Use `git diff` after accepting to see what actually changed - Use the CLI commands. **DO NOT** just copy-paste or manually edit `.snap` files. ## Example: Complete Workflow ```bash # 1. Make a code change to a linter rule # 2. Run tests cargo test -p oxc_linter # 3. See what changed cargo insta pending-snapshots # 4. Review specific snapshot (using Read tool) # Read: crates/oxc_linter/src/snapshots/some_test.snap.new # 5. Accept if correct cargo insta accept -p oxc_linter # 6. Verify with git git diff crates/oxc_linter/src/snapshots/ # 7. Run tests again to ensure everything passes cargo test -p oxc_linter ``` --- **When to use this skill**: When tests fail due to snapshot mismatches or after changing code that affects test outputs. ## Dónde encaja - Categoría: [Testing y QA](https://skillsagentes.com/categorias/testing-qa.md) — Flujos de testing unitario, de integración y end-to-end. - Creador: [oxc-project](https://skillsagentes.com/creators/oxc-project.md) — 4 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Migrate Oxfmt](https://skillsagentes.com/skills/oxc-project/oxc/migrate-oxfmt.md): Guía para migrar un proyecto JavaScript/TypeScript de Prettier o Biome a Oxfmt. - [Performance Lint Rules](https://skillsagentes.com/skills/oxc-project/oxc/performance-lint-rules.md): Guía de rendimiento para implementaciones de reglas del linter de Oxc. Úsalo solo al revisar código Rust bajo crates/oxc_linter/src/rules/ o al auditar esas reglas explícitamente. - [Migrate Oxlint](https://skillsagentes.com/skills/oxc-project/oxc/migrate-oxlint.md): Guía para migrar un proyecto JavaScript/TypeScript de ESLint a Oxlint. ## Skills relacionadas - [Turborepo](https://skillsagentes.com/skills/vercel/turborepo/turborepo.md): Guía sobre Turborepo: turbo.json, pipelines de tareas, dependsOn, caché, remote cache, CLI turbo, --filter, --affected, variables de entorno, paquetes internos y boundaries. - [Add Function Examples](https://skillsagentes.com/skills/vercel/ai/add-function-examples.md): Guía para añadir nuevos ejemplos de funciones de IA, usados para probar características específicas contra las APIs reales de los proveedores. - [Add Harness Package](https://skillsagentes.com/skills/vercel/ai/add-harness-package.md): Guía para añadir nuevos paquetes harness de AI SDK. Úsala al crear un paquete @ai-sdk/harness- que adapte un runtime de coding-agent a HarnessV1. - [Island Rescue](https://skillsagentes.com/skills/vercel/ai/island-rescue.md): Cómo ser rescatado de una isla solitaria. - [Adr Skill](https://skillsagentes.com/skills/vercel/ai/adr-skill.md): Crea y mantiene Architecture Decision Records (ADR) optimizados para agentes de código: propone, redacta, actualiza, acepta/rechaza, deprecia o supersede ADRs usando preguntas socráticas y una checklist de validación. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)