Skip to content

test: run accounts-controller on Vitest - #10551

Open
cryptodev-2s wants to merge 1 commit into
test/vitest-setupfrom
test/vitest-accounts-controller
Open

cryptodev-2s wants to merge 1 commit into
test/vitest-setupfrom
test/vitest-accounts-controller

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Moves @metamask/accounts-controller to Vitest. One of a stack on top of #10546, which added Vitest without migrating anything.

Add vitest.config.mts, delete jest.config.cjs, swap the test scripts and dev dependencies, point the package tsconfig off the repo wide types: ["jest"], and rewrite the test files (jest.* to vi.*, jest.Mocked to the imported Vitest type, requireActual to an awaited importActual, and an explicit vitest import per file since globals is off).

createExpectedInternalAccount moves out of tests/mocks.ts into tests/expectations.ts. It uses expect.any(Number), and an asymmetric matcher from one runner means nothing to the other, while mocks.ts is imported by assets-controllers, still on Jest.

Tests pass with coverage thresholds enforced. yarn lint and yarn constraints are green on this branch alone.

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
    • Not applicable, test only change. Carries the no-changelog label.
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
    • None.

Note

Low Risk
Test-only migration with no production API changes; the split of Vitest-specific matchers into expectations.ts preserves Jest compatibility for shared mocks.

Overview
Migrates @metamask/accounts-controller from Jest to Vitest as part of the repo-wide test-runner rollout. Production code is unchanged; only test tooling and test files are touched.

The package drops jest.config.cjs and Jest-related devDependencies in favor of vitest.config.mjs (same coverage thresholds as before) and vitest scripts in package.json. test-runner-package-map.cjs no longer lists this package as Jest-based. Package tsconfig.json sets compilerOptions.types to [] so repo-wide Jest types do not apply while Vitest runs without globals.

Tests import describe/expect/vi explicitly and replace jest.* with vi.* (including vi.importActual for the uuid mock). createExpectedInternalAccount moves from tests/mocks.ts into new tests/expectations.ts because it uses Vitest’s expect.any(Number); mocks.ts stays free of Vitest so Jest consumers (e.g. assets-controllers) can keep importing it.

Reviewed by Cursor Bugbot for commit 2c3613b. 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 September 28, 2026 20:18
@cryptodev-2s
cryptodev-2s added this pull request to stack #10557 September 28, 2026 20:19
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from 8b32e92 to 67053a2 Compare September 29, 2026 08:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from 26d0583 to 13cd0c5 Compare September 29, 2026 08:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from 67053a2 to b3e82c5 Compare September 29, 2026 09:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from 13cd0c5 to 67d664b Compare September 29, 2026 09:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from b3e82c5 to a1d4e04 Compare September 29, 2026 14:38
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from 67d664b to 19b538e Compare September 29, 2026 14:38
@cryptodev-2s
cryptodev-2s removed this pull request from stack #10557 September 29, 2026 14:40
@cryptodev-2s
cryptodev-2s added this pull request to stack #10578 September 29, 2026 14:41
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from 19b538e to 3b9fa5f Compare September 30, 2026 07:04
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch 2 times, most recently from 364aa75 to 63eccab Compare October 5, 2026 10:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from 3b9fa5f to 2a0fcab Compare October 5, 2026 10:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from 2a0fcab to c101a7a Compare October 12, 2026 14:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from 63eccab to 71c2fed Compare October 12, 2026 14:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from c101a7a to d6f72bf Compare October 12, 2026 15:43
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch 2 times, most recently from 326b876 to 253b29c Compare October 14, 2026 09:23
@cryptodev-2s
cryptodev-2s requested review from a team as code owners October 14, 2026 09:23
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from d6f72bf to b73f918 Compare October 14, 2026 09:23
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from 253b29c to bfbd149 Compare October 14, 2026 12:47
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch 2 times, most recently from 655bb71 to 94f8988 Compare October 14, 2026 12:53
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from 0ca3777 to ac3840f Compare October 14, 2026 13:44
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from 94f8988 to c0a4cda Compare October 14, 2026 13:44
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from eac8ba0 to c533375 Compare October 14, 2026 18:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch 2 times, most recently from 9be48e8 to 7d3768b Compare October 14, 2026 20:18
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch 2 times, most recently from 7d298b8 to e282b91 Compare October 14, 2026 20:37
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch 2 times, most recently from 60962aa to fa046eb Compare October 14, 2026 20:59
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch 2 times, most recently from 0521230 to c1ad23d Compare October 14, 2026 21:27
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from fa046eb to f9f28e3 Compare October 14, 2026 21:27
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from c1ad23d to fd6ff54 Compare October 14, 2026 22:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from f9f28e3 to 7e7d023 Compare October 14, 2026 22:48
@cryptodev-2s
cryptodev-2s removed this pull request from stack #10578 October 14, 2026 22:51
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from fd6ff54 to 83be520 Compare October 15, 2026 10:36
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch 2 times, most recently from 0b21fde to a196bd2 Compare October 15, 2026 11:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from 83be520 to efde443 Compare October 15, 2026 11:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from a196bd2 to 8e3abbd Compare October 15, 2026 11:50
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch 2 times, most recently from c0fd4d7 to b346698 Compare October 15, 2026 12:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch 2 times, most recently from 56d6d16 to fe67e0d Compare October 15, 2026 13:21
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch 2 times, most recently from a2673d1 to f73bc66 Compare October 15, 2026 14:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-sample-controllers branch from fe67e0d to d7f992a Compare October 15, 2026 14:48
@cryptodev-2s
cryptodev-2s changed the base branch from test/vitest-sample-controllers to test/vitest-setup October 15, 2026 14:56
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch 2 times, most recently from 3c575be to f5b5edb Compare October 15, 2026 20:07
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-accounts-controller branch from f5b5edb to 2c3613b Compare October 15, 2026 23:52

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant