Skip to content

[heft-jest-plugin] Migrate from @types/heft-jest to @types/jest#5772

Merged
iclanton merged 5 commits intomicrosoft:mainfrom
iclanton:jest-typings
Apr 15, 2026
Merged

[heft-jest-plugin] Migrate from @types/heft-jest to @types/jest#5772
iclanton merged 5 commits intomicrosoft:mainfrom
iclanton:jest-typings

Conversation

@iclanton
Copy link
Copy Markdown
Member

Summary

Projects in this repo previously used a custom @types/heft-jest type shim for Jest typings, and heft-jest-plugin injected a mocked() global via a jest-global-setup setupFiles entry. Now that @types/jest correctly includes the mocking typings and Jest 30 ships jest.mocked() as the standard API, the shim and workaround are no longer needed.

Changes:

  • Replace @types/heft-jest with @types/jest in all rigs, build tests, samples, and tsconfig.json files
  • Remove jest-global-setup.ts from heft-jest-plugin and its setupFiles config entry
  • Add @types/jest as an optional peer dependency of heft-jest-plugin

Details

The jest-global-setup script was registered as a Jest setupFiles entry and injected mocked() as a global function, because the old @types/heft-jest shim declared it that way. With Jest 30, jest.mocked() is the idiomatic API, so the global injection is nonstandard and the shim is no longer needed. The official @types/jest package (from DefinitelyTyped) provides the correct typings.

This change does not break backwards compatibility for tests that already use jest.mocked(). Tests using a bare mocked() global will need to update to jest.mocked().

How it was tested

Ran rush build and rush test locally across affected packages.

Impacted documentation

None — the @types/heft-jest shim was an implementation detail not covered in public docs.

Replace the custom @types/heft-jest type shim with the official @types/jest
package across all projects. Also removes the jest-global-setup.ts workaround
that injected mocked() as a global — Jest 30 ships jest.mocked() as the
standard API, so the global shim is no longer appropriate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@iclanton iclanton enabled auto-merge (squash) April 15, 2026 15:23
@iclanton iclanton merged commit 826f57f into microsoft:main Apr 15, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants