Skip to content

test: run tests outside src in the shared Vitest config - #10874

Merged
cryptodev-2s merged 1 commit into
mainfrom
test/vitest-include-tests-dir
Oct 21, 2026
Merged

cryptodev-2s merged 1 commit into
mainfrom
test/vitest-include-tests-dir

Conversation

@cryptodev-2s

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

Copy link
Copy Markdown
Contributor

Explanation

The shared Vitest config only includes src/**/*.test.ts, but Jest's default testMatch picks up test files anywhere in a package. Seven packages still on Jest keep tests outside src/, almost all of them in a tests/ directory, so migrating any of them would silently stop running those files while the suite still reported green.

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-runner configuration only; no runtime or API behavior changes.

Overview
Expands the shared package Vitest include glob so suites match Jest-style layouts: tests under src/ still run, and tests/**/*.test.ts is picked up without per-package overrides.

This avoids silently dropping large tests/ suites when migrating packages from Jest (e.g. network-controller), where most coverage can live outside src/. Packages already on Vitest with only src/ tests are unchanged; packages that intentionally ignore tests/ (e.g. wallet-cli) can still exclude that path locally when they migrate.

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

@cryptodev-2s
cryptodev-2s force-pushed the test/vitest-include-tests-dir branch from 2799423 to c0b6fa4 Compare October 20, 2026 23:21
Comment thread vitest.config.packages.js

// The files to include in the test run.
include: ['src/**/*.test.ts'],
include: ['src/**/*.test.ts', 'tests/**/*.test.ts'],

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.

we could also just use configDefaults from https://vitest.dev/config/include

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.

We could, but currently we are following the MetaMask unit testing guidelines, which say that unit tests are located next to source files.

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.

I see thanks, but we still need this PR because of some tests that are still under tests

@cryptodev-2s cryptodev-2s self-assigned this Oct 20, 2026
@cryptodev-2s
cryptodev-2s requested review from a team and mcmire October 20, 2026 23:31

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

I was going to suggest that we override this at the package-level vitest.config.packages.js. But I see now that we're just trying to replicate the existing Jest config. So this seems fine.

@cryptodev-2s
cryptodev-2s added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit ef86942 Oct 21, 2026
367 checks passed
@cryptodev-2s
cryptodev-2s deleted the test/vitest-include-tests-dir branch October 21, 2026 00:16
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