managing-snapshot-tests
Create and validate component snapshots for UI regression testing. Use when performing specialized testing. Trigger with phrases like "update snapshots", "test UI snapshots", or "validate component snapshots".
Best use case
managing-snapshot-tests is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Create and validate component snapshots for UI regression testing. Use when performing specialized testing. Trigger with phrases like "update snapshots", "test UI snapshots", or "validate component snapshots".
Teams using managing-snapshot-tests should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/managing-snapshot-tests/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How managing-snapshot-tests Compares
| Feature / Agent | managing-snapshot-tests | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Create and validate component snapshots for UI regression testing. Use when performing specialized testing. Trigger with phrases like "update snapshots", "test UI snapshots", or "validate component snapshots".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Snapshot Test Manager
## Overview
Create, update, and maintain snapshot tests for UI components and data structures using Jest, Vitest, or pytest snapshot plugins. Manages serialized output snapshots (HTML, JSON, component trees) to detect unexpected changes in rendered output.
## Prerequisites
- Jest or Vitest with built-in snapshot support, or `pytest-snapshot`/`syrupy` for Python
- React Testing Library, Vue Test Utils, or equivalent for component rendering
- Snapshot files committed to version control (`.snap` files or `__snapshots__/` directory)
- Component library with stable prop interfaces
- Code review process that includes snapshot diff review
## Instructions
1. Identify components and data structures suitable for snapshot testing:
- UI components with complex rendered output (navigation bars, forms, cards).
- API response transformers producing structured JSON.
- Configuration generators outputting YAML or TOML.
- Avoid snapshots for highly dynamic content (timestamps, random IDs).
2. Write snapshot tests for each target:
- Render the component with representative props.
- Call `expect(result).toMatchSnapshot()` or `toMatchInlineSnapshot()`.
- Create separate snapshots for each meaningful prop combination.
- Use inline snapshots for small outputs (under 20 lines) for better readability.
3. Organize snapshot files:
- Group snapshots by component in `__snapshots__/ComponentName.test.ts.snap`.
- Name each snapshot descriptively: `"renders with error state"`, `"displays loading skeleton"`.
- Keep snapshot files in the same directory as the test file.
4. Review and update snapshots when intentional changes occur:
- Run `jest --updateSnapshot` or `vitest --update` after verifying changes are correct.
- Review every line of the snapshot diff in pull requests -- do not blindly update.
- Add a comment in the PR explaining why snapshots changed.
5. Clean up obsolete snapshots:
- Run `jest --ci` to detect obsolete snapshots that no longer match any test.
- Delete orphaned `.snap` files for removed components.
- Periodically run snapshot cleanup to prevent stale data.
6. Set up CI to fail on snapshot mismatches without auto-updating:
- Use `--ci` flag which treats missing snapshots as failures.
- Upload snapshot diff output as a CI artifact for review.
7. Consider property-based snapshot alternatives for large components:
- Use `toMatchObject` for partial structure matching.
- Use custom serializers to exclude volatile fields.
## Output
- Snapshot test files (`*.test.ts` or `*.test.tsx`) with `toMatchSnapshot()` assertions
- Snapshot data files (`__snapshots__/*.snap`)
- Snapshot update report listing changed, added, and removed snapshots
- CI configuration preventing accidental snapshot updates in automated runs
- Custom serializer modules for filtering dynamic content
## Error Handling
| Error | Cause | Solution |
|-------|-------|---------|
| Snapshot mismatch on unrelated change | Component depends on a shared style or context provider | Isolate components with wrapper providers; mock global styles |
| Snapshot file is enormous (>1000 lines) | Entire page DOM serialized instead of target component | Narrow the snapshot scope to the specific component subtree; use `container.querySelector` |
| Obsolete snapshot warning | Test was renamed or deleted but `.snap` file remains | Run `jest --updateSnapshot` to remove orphaned entries; delete unused `.snap` files |
| Snapshot differs between local and CI | Different Node.js version or OS renders slightly different output | Pin Node.js version in CI; use `toMatchInlineSnapshot` for exact control |
| Non-deterministic snapshot | Component includes random keys, timestamps, or Math.random() | Mock `Date.now()` and `Math.random()`; use `expect.any(String)` for volatile fields |
## Examples
**React component snapshot test (Jest):**
```tsx
import { render } from '@testing-library/react';
import { Alert } from './Alert';
describe('Alert', () => {
it('renders success variant', () => {
const { container } = render(
<Alert variant="success" message="Operation completed" />
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders error with inline snapshot', () => {
const { container } = render(
<Alert variant="error" message="Something failed" />
);
expect(container.firstChild).toMatchInlineSnapshot(`
<div class="alert alert-error" role="alert">
<span>Something failed</span>
</div>
`);
});
});
```
**Custom serializer to exclude dynamic IDs:**
```typescript
// jest.config.ts
export default {
snapshotSerializers: ['./test/serializers/strip-ids.ts'],
};
// test/serializers/strip-ids.ts
export const serialize = (val: string) =>
val.replace(/id="[a-z0-9-]+"/g, 'id="[dynamic]"');
export const test = (val: unknown) => typeof val === 'string' && val.includes('id=');
```
## Resources
- Jest snapshot testing: https://jestjs.io/docs/snapshot-testing
- Vitest snapshots: https://vitest.dev/guide/snapshot
- React Testing Library: https://testing-library.com/docs/react-testing-library/intro/
- Syrupy (pytest snapshots): https://github.com/toptal/syrupy
- Effective Snapshot Testing: https://kentcdodds.com/blog/effective-snapshot-testingRelated Skills
generating-unit-tests
Test automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions. Use when creating test coverage for functions, classes, or modules. Trigger with phrases like "generate unit tests", "create tests for", or "add test coverage".
managing-test-environments
Test provision and manage isolated test environments with configuration and data. Use when performing specialized testing. Trigger with phrases like "manage test environment", "provision test env", or "setup test infrastructure".
running-smoke-tests
Execute fast smoke tests validating critical functionality after deployment. Use when performing specialized testing. Trigger with phrases like "run smoke tests", "quick validation", or "test critical paths".
tracking-regression-tests
Track and manage regression test suites across releases. Use when performing specialized testing. Trigger with phrases like "track regressions", "manage regression suite", or "validate against baseline".
running-performance-tests
Execute load testing, stress testing, and performance benchmarking. Use when performing specialized testing. Trigger with phrases like "run load tests", "test performance", or "benchmark the system".
running-mutation-tests
Execute mutation testing to evaluate test suite effectiveness. Use when performing specialized testing. Trigger with phrases like "run mutation tests", "test the tests", or "validate test effectiveness".
running-integration-tests
Execute integration tests validating component interactions and system integration. Use when performing specialized testing. Trigger with phrases like "run integration tests", "test integration", or "validate component interactions".
running-e2e-tests
Execute end-to-end tests covering full user workflows across frontend and backend. Use when performing specialized testing. Trigger with phrases like "run end-to-end tests", "test user flows", or "execute E2E suite".
managing-database-tests
Test database testing including fixtures, transactions, and rollback management. Use when performing specialized testing. Trigger with phrases like "test the database", "run database tests", or "validate data integrity".
running-chaos-tests
Execute chaos engineering experiments to test system resilience. Use when performing specialized testing. Trigger with phrases like "run chaos tests", "test resilience", or "inject failures".
managing-ssltls-certificates
Execute this skill enables AI assistant to manage and monitor ssl/tls certificates using the ssl-certificate-manager plugin. it is activated when the user requests actions related to ssl certificates, such as checking certificate expiry, renewing certificates, ... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.
running-load-tests
Create and execute load tests for performance validation using k6, JMeter, and Artillery. Use when validating application performance under load conditions or identifying bottlenecks. Trigger with phrases like "run load test", "create stress test", or "validate performance under load".