Skip to content

feat(snaps-vitest): add Vitest environment and matchers - #4175

Open
ulissesferreira wants to merge 1 commit into
feat/snaps-vitest-packagefrom
feat/snaps-vitest-implementation
Open

ulissesferreira wants to merge 1 commit into
feat/snaps-vitest-packagefrom
feat/snaps-vitest-implementation

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary

Adds the full @metamask/snaps-vitest implementation on top of #4174. It is a Vitest port of @metamask/snaps-jest, with the same end-to-end testing API.

src/
├── environment.ts       # Vitest environment: starts server, exposes installSnap
├── setup.ts             # registers matchers
├── matchers.ts          # toRespondWith, toRender, toSendNotification, ...
├── helpers.ts           # installSnap, getMockAccount, getStateFrom* helpers
├── options.ts           # environmentOptions validation
├── global.ts            # `expect` type augmentation (@vitest/expect)
├── internals/           # server, logger, account helpers
└── test-utils/          # test-only helpers and fixture Snap

test/
└── e2e.test.ts          # installSnap + matcher smoke test

compat (not committed)
└── Bitcoin and Solana suites from internal-snaps, run against the built dist

Key adaptation to this monorepo:

  • Uses workspace snaps-controllers, snaps-sdk, snaps-simulation, and snaps-utils.
  • Uses Vitest ^3.1.1, matching the version already installed here, and the Vitest 3 environment API (transformMode).
  • Configures Snap JSX through Vite esbuild (jsx: 'automatic', jsxDev: false), matching the production Snaps runtime.
  • Uses @metamask/snaps-utils/test-utils instead of the vendored test-utils shim used in the standalone project.
  • Matcher types augment Vitest's Assertion and AsymmetricMatchersContaining interfaces.

Evidence

  • Before: feat(snaps-vitest): scaffold package #4174 contains only the package scaffold and config helper.
    After:
    • yarn workspace @metamask/snaps-vitest run build, lint, and test pass.
    • Package suite: 106 passed (9 files).
    • Consumer smoke test using the built getSnapsVitestConfig + packed dist: 1 passed.
    • Bitcoin internal-snaps integration suite against the built package (fresh regtest chain): 53 passed / 7 skipped, matching the Jest baseline.
    • Solana tests importing snaps-jest (4 files) against the built package: 15 passed / 1 skipped, matching the Jest baseline.

Merge Danger

Door: two-way

Blast Radius: low

New package only; the shared-file wiring is in #4174. Merge #4174 first.

@ulissesferreira
ulissesferreira force-pushed the feat/snaps-vitest-implementation branch 3 times, most recently from 3d86932 to 9c83759 Compare November 5, 2026 21:19
@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (feat/snaps-vitest-package@7ee7176). Learn more about missing BASE report.

Additional details and impacted files
@@                     Coverage Diff                      @@
##             feat/snaps-vitest-package    #4175   +/-   ##
============================================================
  Coverage                             ?   98.69%           
============================================================
  Files                                ?      429           
  Lines                                ?    12533           
  Branches                             ?     1986           
============================================================
  Hits                                 ?    12369           
  Misses                               ?      164           
  Partials                             ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ulissesferreira
ulissesferreira marked this pull request as ready for review November 5, 2026 21:37
@ulissesferreira
ulissesferreira requested a review from a team as a code owner November 5, 2026 21:37
@ulissesferreira
ulissesferreira force-pushed the feat/snaps-vitest-implementation branch from 9c83759 to 121f10d Compare November 6, 2026 09:45

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant