Skip to content

test: run approval-controller on Vitest - #10549

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

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

Conversation

@cryptodev-2s

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

Copy link
Copy Markdown
Contributor

Explanation

Moves @metamask/approval-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).

The error expectations needed a real change, because Vitest compares a thrown value strictly and the old toThrow(plainObject) cannot match a JsonRpcError. That is split into #10576 so it lands on Jest and is reviewed on its own; with it in place the diff here is mechanical.

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 and tooling changes; no production code in ApprovalController is modified.

Overview
Migrates @metamask/approval-controller from Jest to Vitest as part of the repo-wide test runner rollout (stacked on shared Vitest package config).

The package drops jest.config.cjs and adds vitest.config.mjs merged from vitest.config.packages.mjs, keeping 100% coverage thresholds. package.json test scripts and devDependencies swap Jest/ts-jest for Vitest; @metamask/approval-controller is removed from test-runners.cjs’s Jest package list.

ApprovalController.test.ts is updated mechanically: jest.* → vi.*, explicit vitest imports (globals off), flushPromises from tests/vitest/helpers.js, and package tsconfig.json sets types: [] so repo-wide Jest types do not apply. Lint suppressions drop the Jest config entry and add vitest/no-conditional-in-test for the test file.

Reviewed by Cursor Bugbot for commit 6a453a3. 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-approval-controller branch from 57a9877 to e91bdd0 Compare September 29, 2026 08:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from c4fcfb2 to 54879b9 Compare September 29, 2026 08:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from e91bdd0 to ad263be Compare September 29, 2026 09:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 54879b9 to 79b9e14 Compare September 29, 2026 09:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from ad263be to c679083 Compare September 29, 2026 14:38
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 79b9e14 to 12980e9 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-polling-controller branch from 12980e9 to d248c2e Compare September 30, 2026 07:04
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from c679083 to 80c7790 Compare September 30, 2026 07:04
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from d248c2e to dbc8afc Compare October 5, 2026 10:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from 80c7790 to 23f8c46 Compare October 5, 2026 10:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from 23f8c46 to dffdbe0 Compare October 12, 2026 14:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from dbc8afc to 79ecc80 Compare October 12, 2026 14:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from dffdbe0 to fe8b81c Compare October 12, 2026 15:43
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 79ecc80 to 56ec0c8 Compare October 12, 2026 15:43
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 56ec0c8 to 0027854 Compare October 14, 2026 09:23
@cryptodev-2s
cryptodev-2s requested a review from a team as a code owner October 14, 2026 09:23
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from fe8b81c to 4c4749e Compare October 14, 2026 09:23
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 0027854 to 52c697b Compare October 14, 2026 12:47
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch 2 times, most recently from 642b296 to d3960d8 Compare October 14, 2026 12:53
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 342e176 to 09e3b96 Compare October 14, 2026 13:44
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from d3960d8 to 8112a4b Compare October 14, 2026 13:44
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch 2 times, most recently from b549cff to 9373d55 Compare October 14, 2026 18:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from bf6fb8a to 2d85bf5 Compare October 14, 2026 18:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from 9373d55 to b2c633b Compare October 14, 2026 20:18
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 2d85bf5 to 3657884 Compare October 14, 2026 20:18
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from b2c633b to acb7896 Compare October 14, 2026 20:37
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch 2 times, most recently from 72146c5 to 85f9712 Compare October 14, 2026 20:59
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from acb7896 to 2369da2 Compare October 14, 2026 20:59
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 85f9712 to 4ada28b Compare October 14, 2026 21:27
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from 2369da2 to 68df0bc Compare October 14, 2026 21:27
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 4ada28b to eb6f138 Compare October 14, 2026 22:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from 68df0bc to e32a39c Compare October 14, 2026 22:48

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e32a39c. Configure here.

Comment thread packages/approval-controller/src/ApprovalController.test.ts
@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-approval-controller branch from e32a39c to d168357 Compare October 15, 2026 10:36
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch 2 times, most recently from 5d2a8a8 to 42f3009 Compare October 15, 2026 11:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from d168357 to e25274a Compare October 15, 2026 11:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 42f3009 to 3ca6b4f Compare October 15, 2026 11:50
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from e25274a to 4b735f3 Compare October 15, 2026 11:50
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 3ca6b4f to d648832 Compare October 15, 2026 12:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch 2 times, most recently from 8b861e8 to 55fa07c Compare October 15, 2026 13:21
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from d648832 to 4a2b96c Compare October 15, 2026 13:21
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from 55fa07c to b9164d4 Compare October 15, 2026 14:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-polling-controller branch from 4a2b96c to 2bbfd60 Compare October 15, 2026 14:48
@cryptodev-2s
cryptodev-2s changed the base branch from test/vitest-polling-controller to test/vitest-setup October 15, 2026 14:56
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-approval-controller branch from b9164d4 to 6a453a3 Compare October 15, 2026 15:38

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