medium

Snapshot mismatch — expected value to match snapshot

The rendered output does not match the stored snapshot. The component output changed since the snapshot was last updated.

Common Causes

  1. 1Component was intentionally updated but snapshot not refreshed
  2. 2Dynamic content (dates, IDs) changed between runs
  3. 3Different environment produces different output
  4. 4Dependency update changed rendered markup

How to Fix

Update the snapshot after verifying the change is correct

# Update all snapshots:
npx jest --updateSnapshot

# Update specific test file:
npx jest path/to/test --updateSnapshot

Review the diff carefully, then update the snapshot if the change is intentional.

Use snapshot serializers for dynamic content

// jest.config.ts
export default {
  snapshotSerializers: ['jest-serializer-html'],
};

// In test:
expect(component).toMatchSnapshot({
  createdAt: expect.any(String),
});

Use property matchers to ignore dynamic values like timestamps or generated IDs.

How ObserveOne Helps

ObserveOne tracks visual changes across deployments and identifies unintended UI regressions.

Start Monitoring Free

Related Errors