mock-to-internals-migration

Migrates Vitest mock APIs to Bun's native test runner while preserving test integrity.

437|45|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/ZaxbyHub/opencode-swarm --skill mock-to-internals-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mock-to-internals-migration
Source: https://github.com/ZaxbyHub/opencode-swarm/tree/main/.opencode/skills/generated/mock-to-internals-migration
Command: npx skills add https://github.com/ZaxbyHub/opencode-swarm --skill mock-to-internals-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Migrating test mocks from Vitest to Bun's native test runner introduces common pitfalls like broken test isolation, missing real module exports in mocks, and broken barrel import patterns that can silently break test suites and introduce flaky test behavior.

Core Features & Use Cases

  • Strict Procedural Guardrails: Defines required pre- and post-migration steps including baseline test runs, barrel export audits, and mock spread validation to prevent common migration errors.
  • Forbidden Shortcut Prohibitions: Explicitly bans risky practices like inventing custom gating mechanisms or dismissing post-change test failures as pre-existing without verification.
  • Validation Checklists: Provides dedicated reviewer and test engineer checks to verify command transformation idempotency, mock correctness, and test suite integrity after migration.
  • Use Case: Ideal for development teams moving their test infrastructure from Vitest to Bun, ensuring mock conversions preserve existing test coverage and behavior without regressions.

Quick Start

Use the mock-to-internals-migration skill to convert all Vitest mock calls in your project's test suite to compatible Bun internal mock patterns while maintaining full test integrity.

Frequently Asked Questions about mock-to-internals-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Vitest mocks to Bun's native test runner without breaking test isolation?

Migrating Vitest mocks to Bun requires converting vi.fn(), vi.spyOn(), and vi.mock() calls to Bun's internal mock system while enforcing strict procedural guardrails, barrel export audits, and mock spread validation to preserve test isolation.

What causes broken test isolation when converting vi.mock() to Bun internals?

Broken test isolation occurs during vi.mock() conversion when barrel import patterns are disrupted or real module exports are missing from mocks. Applying validation checklists and command transformation idempotency requirements prevents this flaky behavior.

How do I convert vi.spyOn and vi.fn calls to Bun test internals step by step?

Converting vi.spyOn and vi.fn calls involves running baseline tests, auditing barrel exports, transforming mock APIs to Bun internals, and verifying command transformation idempotency through dedicated reviewer and test engineer validation checklists.

Can I use Bun's internal mock system to preserve barrel exports from Vitest?

Yes, Bun's internal mock system can preserve barrel exports by applying mock spread validation and barrel export audits during migration. This ensures migrated mocks retain real module exports and maintain full test suite integrity.

Why are my Bun test mocks missing real module exports after migrating from Vitest?

Missing real module exports after Vitest to Bun mock migration typically result from skipping barrel export audits or failing mock spread validation. Banning forbidden shortcuts and enforcing post-change test verification resolves these regressions.

What are the limitations of converting Vitest mock APIs to Bun test internals?

Limitations include the prohibition of custom gating mechanisms and the inability to dismiss post-change test failures as pre-existing without verification. Strict pre- and post-migration validation checklists are mandatory to ensure full test suite integrity.