Skip to content

test: use typed Vitest module mock factories - #10904

Merged
cryptodev-2s merged 4 commits into
mainfrom
test/vitest-typed-mock-factories
Oct 20, 2026
Merged

cryptodev-2s merged 4 commits into
mainfrom
test/vitest-typed-mock-factories

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Use Vitest's module-promise overload for the remaining partial mock factories in keyring-controller, phishing-controller, and user-operation-controller. Partial factories receive the inferred importOriginal helper, removing the repeated module path and explicit typeof import(...) generic.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Test-only mock setup refactors with no production code or runtime behavior changes.

Overview
This PR refactors partial vi.mock factories in controller test files to Vitest’s typed module-promise overload: vi.mock(import('…'), async (importOriginal) => ({ ...(await importOriginal()), … })).

Affected tests: uuid v4 stub in keyring-controller, and @metamask/controller-utils partial mocks (safelyExecuteWithTimeout or query) in phishing-controller and user-operation-controller. Behavior is unchanged—still spreads the real module and overrides specific exports—but drops duplicate module path strings and explicit typeof import(...) generics in favor of inferred importOriginal. Follow-up to the same pattern used in #10871.

Reviewed by Cursor Bugbot for commit a5b1baa. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s
cryptodev-2s requested review from a team as code owners October 20, 2026 10:10
@cryptodev-2s
cryptodev-2s deployed to default-branch October 20, 2026 10:10 — with GitHub Actions Active
@cryptodev-2s
cryptodev-2s marked this pull request as draft October 20, 2026 10:15
@cryptodev-2s
cryptodev-2s marked this pull request as ready for review October 20, 2026 10:46
@cryptodev-2s
cryptodev-2s deployed to default-branch October 20, 2026 10:46 — with GitHub Actions Active
@cryptodev-2s
cryptodev-2s added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 20, 2026
@cryptodev-2s
cryptodev-2s added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 4673007 Oct 20, 2026
206 checks passed
@cryptodev-2s
cryptodev-2s deleted the test/vitest-typed-mock-factories branch October 20, 2026 15:48

This branch was successfully deployed

1 active deployment
default-branch — a5b1baa3 Deployed Oct 20, 2026 by cryptodev-2s via Determine whether this PR is a release PR #5689
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.

4 participants