Skip to content

test: run network-controller on Vitest - #10873

Merged
cryptodev-2s merged 13 commits into
mainfrom
test/vitest-network-controller
Oct 23, 2026
Merged

cryptodev-2s merged 13 commits into
mainfrom
test/vitest-network-controller

Conversation

@cryptodev-2s

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

Copy link
Copy Markdown
Contributor

Explanation

Moves @metamask/network-controller to Vitest, including runtime and type tests.

With the final Jest workspace migrated, removes the remaining shared Jest configuration, setup files, helpers, typings, and direct dependencies. Cleans up lint configuration, build exclusions, CODEOWNERS generation, and testing documentation.

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

Medium Risk
Large test-runner swap for network-controller (RPC failover, provider, and extensive network-client coverage); production code changes are minimal (mostly test env lint tweaks), but CI signal depends on Vitest parity with the removed Jest setup.

Overview
Completes the monorepo move from Jest to Vitest by migrating @metamask/network-controller—the last Jest workspace—including unit tests, shared network-client suites, and struct type checks ( tstyche → vitest expectTypeOf ). Tests now use vi for mocks, timers, and spies; package scripts run vitest instead of Jest/jest-silent-reporter, and the package jest.config.cjs is removed in favor of vitest.config.ts.

With no Jest packages left, this PR removes shared Jest infrastructure: root jest.config.packages.cjs, Jest from root package.json and LavaMoat allow-scripts, Jest-specific oxlint rules and test-runner-package-map, and jest.config.* entries from CODEOWNERS and CI path ignores. AGENTS.md, testing, and package migration docs now describe Vitest-only workflows; assorted tests only update eslint-disable comments from jest/* to vitest/*.

Reviewed by Cursor Bugbot for commit 1aa7a99. 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 16, 2026 20:06
@cryptodev-2s
cryptodev-2s deployed to default-branch October 16, 2026 20:06 — with GitHub Actions Active
@cryptodev-2s cryptodev-2s self-assigned this Oct 19, 2026
@cryptodev-2s
cryptodev-2s marked this pull request as draft October 20, 2026 14:59
@cryptodev-2s
cryptodev-2s marked this pull request as ready for review October 22, 2026 13:18
@cryptodev-2s
cryptodev-2s deployed to default-branch October 22, 2026 13:18 — with GitHub Actions Active
expect(onBreakListener).toHaveBeenCalledTimes(1);
expect(onBreakListener).toHaveBeenCalledWith({
error: new Error("Fetch failed with status '503'"),
error: new HttpError(503),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The listener receives an HttpError with an httpStatus property. Jest compared errors by message, so the previous new Error(...) expectation passed. Vitest also compares additional error properties, so we use new HttpError(503) to match the actual callback payload.

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.

Makes sense!

name: basename(dirname(fileURLToPath(import.meta.url))),

typecheck: {
ignoreSourceErrors: true,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Source checking is handled by lint:tsc:check. This suppresses Vitest’s source diagnostics, including unbuilt project references; .test-d.ts failures still fail the test run.

@cryptodev-2s
cryptodev-2s added this pull request to stack #11032 October 23, 2026 09:41
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-network-controller branch from 84e8630 to 7e05b77 Compare October 23, 2026 17:17
@cryptodev-2s
cryptodev-2s enabled stacked auto-merge October 23, 2026 17:46
jest.spyOn(Date, 'now').mockReturnValue(FAKE_DATE_NOW_MS);
});

afterEach(() => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

was needed for jest-when

@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-network-controller branch from b849522 to 5b0ead4 Compare October 23, 2026 20:06
@cryptodev-2s
cryptodev-2s requested review from a team as code owners October 23, 2026 21:10
Move conditional-test lint exceptions to bulk suppressions, remove redundant constructor-type comments, and drop unused jest-when from the lockfile.

Retain the real timer yield: replacing it with flushPromises made the existing 502-retry test time out.
Move conditional expectations to bulk suppressions, remove obsolete disable directives, and drop the timer explanation while retaining the timer yield.
Replace duplicated Constructable aliases with the exported @vitest/spy type and declare the existing 5.0.3 version as a direct development dependency.
Use the package naming pattern shared by other Vitest configs and remove redundant configuration comments and the unnecessary lint directive.
Drop the unused TSTyche entry after rebasing the Vitest migration onto current main.
All shared-helper consumers now use Vitest. Restore the original helper structure with vi.fn defaults and the Vitest Mock type, removing the obsolete captureException option and caller overrides.
Refresh the generated lockfile after migrating the final Jest workspace, without changing remaining dependency versions or the test-runner map interface.
@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-network-controller branch from 1aa7a99 to 31a5fd0 Compare October 23, 2026 21:23

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

Amazing!! Great job! 🎉

expect(onBreakListener).toHaveBeenCalledTimes(1);
expect(onBreakListener).toHaveBeenCalledWith({
error: new Error("Fetch failed with status '503'"),
error: new HttpError(503),

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.

Makes sense!

@cryptodev-2s
cryptodev-2s added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit 4ff142e Oct 23, 2026
944 of 946 checks passed
@cryptodev-2s
cryptodev-2s deleted the test/vitest-network-controller branch October 23, 2026 21:36
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