npx skills add ...
npx skills add getsentry/sentry --skill generate-snapshot-tests
Generate snapshot test files for Sentry frontend React components. Use when asked to "generate snapshot tests", "add snapshot tests", "create visual snapshots", "write snapshot tests", "add visual regression tests", or "snapshot this component". Accepts an optional component path or name via $ARGUMENTS.
npx skills add getsentry/sentry --skill generate-snapshot-tests
Generate a *.snapshots.tsx file colocated with a Sentry React component, following the established pattern used by core design system components.
If $ARGUMENTS is provided, treat it as a path or component name. Otherwise ask the user which component to snapshot.
Search strategies:
Use Glob or Grep to find the file if the exact path is unknown.
Read the component source file to understand:
Props / <ComponentName>Props typevariant, priority, size)disabled, checked, busy)onChange={() => {}} or similar no-op handlers)| Condition | Import style |
|---|---|
Component lives under static/app/components/core/ AND is published as @sentry/scraps/<name> | import {ComponentName, type ComponentNameProps} from '@sentry/scraps/<name>'; |
Component lives under static/app/components/core/ but is NOT in @sentry/scraps | // eslint-disable-next-line @sentry/scraps/no-core-import -- SSR snapshot needs direct import to avoid barrel re-exports with heavy depsimport {ComponentName, type ComponentNameProps} from 'sentry/components/core/<path>'; |
| All other components | import {ComponentName, type ComponentNameProps} from 'sentry/components/<path>'; |
To check if a component is in @sentry/scraps, look for an existing import using @sentry/scraps/<name> in neighboring files, or check if other snapshot files in the same directory use @sentry/scraps.
Read the TypeScript props and classify them:
| Prop type | Action |
|---|---|
Union of string literals ('sm' | 'md' | 'lg') | Snapshot each value with it.snapshot.each |
Boolean toggle with visual impact (disabled, checked) | Snapshot true and false states |
| Boolean flag with no visual test value | Skip or add a single named snapshot |
children / className / style / event handlers | Skip — not visually interesting on their own |
Prioritize props that change the component's visual appearance substantially. For interactive components (inputs, toggles), always include disabled/checked states.
Name the output file <component-name>.snapshots.tsx, colocated with the component source file.
Always wrap in light/dark theme loop:
it.snapshot.each — for union prop variantsUse when iterating over multiple values of a single prop:
The third argument to it.snapshot.each is the metadata function — include all props that vary in the snapshot. This metadata is used for snapshot naming and diffing.
it.snapshot — for single named snapshotsUse for one-off states (disabled, checked combinations, etc.):
Pass metadata as a third argument when it adds useful snapshot context:
Match container sizing to what makes the component readable:
| Situation | Wrapper |
|---|---|
| Default | <div style={{padding: 8}}> |
| Width-sensitive (alerts, text) | <div style={{padding: 8, width: 400}}> |
| Narrow (icons, small controls) | <div style={{padding: 8}}> |
For components that require event handlers (inputs, checkboxes, radios, switches), pass no-op handlers to satisfy required props:
Order cases from most impactful to least:
When a component has multiple meaningful boolean or variant props that combine independently, add separate it.snapshot.each blocks per combination:
Before finishing:
<component-name>.snapshots.tsx and colocated with the componentlight and dark themes are covered via describe.eachno-restricted-imports ESLint suppression comment is present on the theme importit.snapshot.each callsonChange={() => {}}) provided for required event props@sentry/scraps/<name> if available, otherwise the direct sentry/components/... path with the no-core-import suppression