Skip to content

test: run controller-utils on Vitest - #10553

Merged
cryptodev-2s merged 7 commits into
mainfrom
test/vitest-controller-utils
Oct 16, 2026
Merged

cryptodev-2s merged 7 commits into
mainfrom
test/vitest-controller-utils

Conversation

@cryptodev-2s

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

Copy link
Copy Markdown
Contributor

Explanation

Moves @metamask/controller-utils to Vitest.

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; production library code is unchanged aside from lockfile transitive deps for jsdom.

Overview
Migrates @metamask/controller-utils from Jest to Vitest, following the monorepo’s shared vitest.config.packages.js pattern.

Test scripts and devDependencies now use Vitest and jsdom instead of Jest, jest-environment-jsdom, ts-jest, and the custom Jest jsdom environment (including TextEncoder shims). A new vitest.config.js sets the jsdom environment and coverage thresholds aligned with the old Jest setup.

Unit tests import describe / expect / it (and vi for mocks and fake timers) from Vitest; create-service-policy.test.ts is the bulk of the mechanical jest → vi rewrites. tsconfig.json drops Jest types, test-runner-package-map.cjs no longer lists this package under Jest, and oxlint-suppressions.json is updated for removed Jest config paths and new Vitest lint suppressions.

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

@cryptodev-2s
cryptodev-2s requested a review from a team as a code owner September 28, 2026 20:18
@cryptodev-2s
cryptodev-2s added this pull request to stack #10557 September 28, 2026 20:19
@socket-security

socket-security Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedjsdom@​27.4.09510010098100

View full report

@socket-security

socket-security Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Warning

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Priority Alert  (click "▶" to expand/collapse) Action
Low priority
Potential code anomaly (AI signal): npm ws is 75.0% likely to have a medium risk anomaly

Notes: The code implements a standard EventTarget-like mixin for wrapping event listeners and dispatching events to user callbacks. There are no suspicious patterns such as dynamic code execution, hardcoded secrets, or network activity. The risk is contingent on what the consumer does inside their handlers; the snippet itself does not introduce malware or data leakage mechanisms beyond normal event dispatch. Overall security risk is low in isolation.

Confidence: 0.75

Severity: 0.50

From: package.json → npm/jsdom@27.4.0 → npm/@docusaurus/core@3.10.2 → npm/@docusaurus/preset-classic@3.10.2 → npm/jest-environment-jsdom@30.5.2 → npm/vitest@5.0.3 → npm/web3@4.16.0 → npm/ws@8.22.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ws@8.22.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Low priority
Potential code anomaly (AI signal): npm css-tree is 78.0% likely to have a medium risk anomaly

Notes: The code is a standard, well-scoped parser fragment for a DSL-like FeatureFunction construct. It uses dynamic feature dispatch with proper balance checks and safe fallbacks, and emits a consistent AST node. No malicious behavior detected; the main risks relate to misconfiguration of the features map rather than code-level exploits.

Confidence: 0.78

Severity: 0.58

From: packages/controller-utils/package.json → npm/jsdom@27.4.0 → npm/css-tree@3.2.1

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/css-tree@3.2.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Low priority
Potential code anomaly (AI signal): npm jsdom is 90.0% likely to have a medium risk anomaly

Notes: This file implements a Window-like global for a DOM environment (jsdom-style). It is not malicious by intent: there are no hardcoded credentials, exfiltration paths, backdoors, or process-spawning operations present. However, it deliberately includes an ability to execute arbitrary script strings inside a vm context when the createWindow option runScripts is set to 'dangerously' (or 'outside-only' for some vm usage). That feature is a significant security hazard if untrusted data can reach timer handlers or other script sources. Consumers must ensure runScripts is not enabled for untrusted inputs or otherwise sanitize/avoid passing string handlers. Overall: functional DOM environment code with a notable, explicit code-execution risk when configured to allow it.

Confidence: 0.90

Severity: 0.60

From: packages/controller-utils/package.json → npm/jsdom@27.4.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/jsdom@27.4.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn

View full report

@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from 68d12f9 to 675508f Compare September 29, 2026 08:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from b92fe81 to 175e025 Compare September 29, 2026 08:11
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from 675508f to 44ee6e0 Compare September 29, 2026 09:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from 175e025 to 186a8bd Compare September 29, 2026 09:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from 44ee6e0 to 9f54633 Compare September 29, 2026 14:38
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from 186a8bd to 69b48d1 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-keyring-controller branch from 9f54633 to 562489c Compare September 30, 2026 07:04
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch 2 times, most recently from 289154f to 3cec491 Compare October 5, 2026 10:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from 562489c to 5cc065d Compare October 5, 2026 10:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from 3cec491 to eb6905d Compare October 12, 2026 14:02
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch 2 times, most recently from 4e2a256 to b5e5992 Compare October 12, 2026 15:43
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from eb6905d to 425f889 Compare October 12, 2026 15:43
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from b5e5992 to 0e78d97 Compare October 14, 2026 09:24
@cryptodev-2s
cryptodev-2s requested review from a team as code owners October 14, 2026 09:24
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from 425f889 to b5450af Compare October 14, 2026 09:24
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from 0e78d97 to 02a0548 Compare October 14, 2026 12:47
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch 2 times, most recently from e837efa to d77b580 Compare October 14, 2026 12:53
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from 86786bb to 25334b8 Compare October 15, 2026 11:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from 2dcc5b9 to 4fe325d Compare October 15, 2026 11:50
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch 2 times, most recently from 3126f77 to f31c96c Compare October 15, 2026 12:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from 4fe325d to ae3585d Compare October 15, 2026 12:20
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from f31c96c to e5aee1b Compare October 15, 2026 13:21
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from ae3585d to 4665ce9 Compare October 15, 2026 13:21

@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.

Stale Bugbot comment from a previous run.

Comment thread packages/controller-utils/package.json
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-keyring-controller branch from 4665ce9 to 83f3081 Compare October 15, 2026 14:48
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from e5aee1b to db2b678 Compare October 15, 2026 14:48
@cryptodev-2s
cryptodev-2s changed the base branch from test/vitest-keyring-controller to test/vitest-setup October 15, 2026 14:56
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from db2b678 to 424497f Compare October 15, 2026 15:38

@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 424497f. Configure here.

Comment thread packages/controller-utils/vitest.config.js
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch 4 times, most recently from f478ce0 to bb32e5f Compare October 16, 2026 08:59
Base automatically changed from test/vitest-setup to main October 16, 2026 09:52
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from bb32e5f to 380d4b6 Compare October 16, 2026 11:25
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-controller-utils branch from 380d4b6 to e19d14b Compare October 16, 2026 11:50
Comment thread packages/controller-utils/vitest.config.js Outdated

@mcmire mcmire left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM.

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.

2 participants