Skip to content

Port snapshot utilities and serializers to Vitest - #80867

Closed
ciampo wants to merge 1 commit into
codex/vitest-04-console-reportingfrom
codex/vitest-05-snapshot-parity
Closed

ciampo wants to merge 1 commit into
codex/vitest-04-console-reportingfrom
codex/vitest-05-snapshot-parity

Conversation

@ciampo

@ciampo ciampo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What?

Part of #80855. Stacked on #80865; review only the fifth commit in this PR.

TL;DR — snapshot parity: Replaces the private Vitest dependency on snapshot-diff with public Vitest snapshot APIs, ports the style-diff and popover matchers, and proves the Emotion serializer format before snapshot-heavy packages move.

Why?

Snapshot consumers must not migrate until their custom matchers and serializers have a verified Vitest implementation. This isolates snapshot-format changes from later component-test migrations and keeps snapshot-diff available only to the remaining Jest partition.

How?

  • Implements toMatchDiffSnapshot and toMatchStyleDiffSnapshot with Vitest's public Snapshots API and matcher-context diff utilities.
  • Ports toBePositionedPopover with explicit Vitest imports.
  • Registers an unquoted snapshot-diff serializer and the existing Emotion serializer behavior in the Vitest Testing Library setup.
  • Adds compatibility coverage for object diffs, custom annotations, style diffs, positioned popovers, non-empty Emotion styles, and empty styled-component labels.
  • Adds @emotion/styled to the test-infrastructure workspace that directly imports it.

No existing baseline snapshot was regenerated or changed. This PR adds two reviewed compatibility snapshot files:

  • the diff snapshot records object visibility, custom array annotations, and red-to-blue style declarations;
  • the Emotion snapshot records the empty EmptyBox label and normalized emotion-0 class, while the non-empty CSS format is reviewed inline.

The Jest partition retains snapshot-diff, its serializer, and existing consumers until those packages migrate.

Testing Instructions

  1. Run npm run test:unit:routing; expect 995 Jest baseline files, 1 Vitest baseline file, and 4 added Vitest compatibility files.
  2. Run npm run test:unit:vitest -- --reporter=dot; expect 5 files and 33 tests to pass.
  3. Run the Vitest suite as each of the four --shard=N/4 partitions and confirm every shard passes.
  4. Inspect both new snapshot files and confirm the four formats listed above are intentional.
  5. Run npm run lint:pkg-json, npm run lint:lockfile, and git diff --check.

Locally verified routing, the complete Vitest partition, all four shards, targeted strict ESLint, package and lockfile validation, formatting, and pre-commit checks.

Testing Instructions for Keyboard

Not applicable; this PR does not change UI behavior.

Screenshots or screencast

Not applicable.

Use of AI Tools

Codex was used to inspect the existing Jest snapshot behavior, verify Vitest's public matcher and snapshot APIs, implement the compatibility layer, review each new snapshot, and run the reported checks. The resulting changes and claims were reviewed against the repository configuration.

@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.76 MB

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant