generate-snapshot-tests

Generate visual snapshot test files for Sentry React components.

44.7k|4.8k|Updated Aug 30, 2010
One-click install
npx skills add https://github.com/getsentry/sentry --skill generate-snapshot-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generate-snapshot-tests
Source: https://github.com/getsentry/sentry/tree/main/.agents/skills/generate-snapshot-tests
Command: npx skills add https://github.com/getsentry/sentry --skill generate-snapshot-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing consistent visual regression snapshot tests for React components is repetitive and error-prone, requiring knowledge of Sentry's theme setup, import conventions, and snapshot naming patterns.

Core Features & Use Cases

  • Automated Snapshot File Generation: Creates colocated <component-name>.snapshots.tsx files following Sentry's established design system patterns.
  • Prop Analysis: Reads component TypeScript props to identify union variants, boolean toggles, and interactive states worth snapshotting.
  • Theme Coverage: Automatically wraps all snapshots in light and dark theme loops using describe.each.
  • Use Case: When adding a new core component like a Switch or Alert, ask the Skill to generate snapshot tests and it produces a complete file covering variants, sizes, disabled states, and both themes with correct imports and metadata.

Quick Start

Ask the AI to generate snapshot tests for the Button component in static/app/components/core/button.

Frequently Asked Questions about generate-snapshot-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate snapshot tests for a React component in Sentry?

Provide the component path or name as an argument, and the Skill locates the source file, analyzes its props, and writes a colocated <component-name>.snapshots.tsx file. It covers union prop variants, boolean states, and both light and dark themes.

What props should be included in visual snapshot tests?

Snapshot union string literal props like variant or size, and boolean toggles with visual impact like disabled or checked. Skip children, className, style, and event handlers since they are not visually interesting on their own.

When should I import from @sentry/scraps versus a direct path?

Use @sentry/scraps/<name> when the component is published in that package. Otherwise import directly from sentry/components/... with the @sentry/scraps/no-core-import ESLint suppression comment to avoid heavy barrel re-exports.

Why do snapshot tests need both light and dark themes?

Sentry components render differently across themes, so visual regressions can appear in only one mode. The Skill wraps all cases in describe.each over light and dark themes using ThemeProvider with direct theme imports.

How do interactive components handle required event handlers in snapshots?

Pass no-op handlers like onChange={() => {}} to satisfy required props for inputs, checkboxes, and switches. Always include disabled and checked/unchecked state combinations for these components.