Skip to content

Migrate Block Library Tests to Vitest - #80972

Closed
ciampo wants to merge 1 commit into
codex/vitest-73-block-library-jsxfrom
codex/vitest-74-block-library
Closed

Migrate Block Library Tests to Vitest#80972
ciampo wants to merge 1 commit into
codex/vitest-73-block-library-jsxfrom
codex/vitest-74-block-library

Conversation

@ciampo

@ciampo ciampo commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What?

See #80855.

TL;DR: This slice migrates Block Library's 55 unit-test files from Jest to Vitest. The required change classes are explicit Vitest imports, ESM-compatible dynamic mock factories, the Vitest Testing Library matcher entrypoint, shared integration fake-timer helpers, and an audited snapshot key/header update.

Why?

Block Library was one of the four remaining Jest-owned areas in the repository. Migrating it reduces the residual Jest partition while preserving the package's 669 tests and its existing Testing Library-based authoring model.

How?

  • Routes packages/block-library through the private Vitest jsdom project.
  • Replaces Jest globals and runtime require calls with explicit Vitest imports and ESM-compatible mocks.
  • Keeps @testing-library/react and @testing-library/user-event; only the matcher registration changes to @testing-library/jest-dom/vitest.
  • Ports the shared integration fake-timer helpers to Vitest's public timer APIs. Vitest modern timers replace the Jest-only legacy-timer mode.
  • Updates the sole snapshot's runner header and hierarchical key. Its serialized body was compared byte-for-byte and is unchanged.
  • Adds Vitest as a direct development dependency of the workspace that imports it.

Testing Instructions

  1. npm run test:unit:vitest -- packages/block-library
    • 55 files passed, 669 tests passed, 1 snapshot passed.
  2. npm run test:unit:vitest
    • 806 files passed, 2 skipped; 31,852 tests passed, 8 skipped.
  3. npm run test:unit -- --runInBand
    • 194 suites passed; 2,898 tests passed; 25 snapshots passed.
  4. npm run test:unit:validate-migration
    • 194 Jest-owned and 809 Vitest-owned tests; no missing, overlapping, invalid, or orphaned entries.
  5. npm run test:unit:validate-vitest-conventions
    • 809 Vitest tests and 825 ESM graph files pass the repository conventions.
  6. Commit-time formatting, strict JavaScript lint, package metadata, lockfile, and generated API-doc checks pass.

Testing Instructions for Keyboard

Not applicable; this changes test infrastructure only.

Screenshots or screencast

Not applicable.

Use of AI Tools

This migration was implemented with Codex assistance. The resulting diff, snapshot, and verification output were reviewed before publication.

@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.76 MB

compressed-size-action

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 750ee7a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/30550479595
📝 Reported issues:

@ciampo ciampo closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant