Skip to content

chore: migrate from Vitest to Bun test runner and enhance AGENTS.md#438

Merged
paul-phan merged 2 commits into
mainfrom
chore/vitest-to-bun-migration-and-agents-md
Mar 5, 2026
Merged

chore: migrate from Vitest to Bun test runner and enhance AGENTS.md#438
paul-phan merged 2 commits into
mainfrom
chore/vitest-to-bun-migration-and-agents-md

Conversation

@paul-phan
Copy link
Copy Markdown
Member

Summary

This PR combines two major improvements:

1. Vitest → Bun Test Runner Migration

Migrated all test files from Vitest to Bun's native test runner:

  • vi.fn()mock.fn()
  • vi.spyOn()spyOn() from bun:test
  • vi.mock()mock.module()
  • Removed vitest dependencies and config files (vitest.config.ts, vitest.workspace.ts, packages/react/vitest.config.ts)
  • Updated turbo.json with test pipeline
  • Fixed packages without tests (biome, cli) to exit 0 instead of failing

All 161 tests pass across 4 packages:

  • hydrogen: 20 tests
  • react: 91 tests
  • schema: 28 tests
  • i18n: 22 tests

2. Enhanced AGENTS.md Documentation

Created hierarchical AGENTS.md structure:

  • Root AGENTS.md: Comprehensive monorepo guide with updated Bun testing section
  • packages/hydrogen/AGENTS.md: Hydrogen-specific patterns (WeaverseClient, types, utilities)
  • packages/schema/AGENTS.md: Schema package specifics (21 input types, validation, builder API)
  • packages/react/AGENTS.md: React bindings (context, hooks, data-connector system)

Added Core Testing Directive with:

  • Target Selection (80/20 Rule)
  • Structural Integrity (AAA & Naming)
  • Execution & Validation (F.I.R.S.T. & TDD)

Test plan

  • bun run test — all 161 tests pass
  • bun run typecheck — 4 packages, all pass
  • bun run biome — 64 files, no errors

- Migrate all test files from Vitest to Bun's native test runner
  - vi.fn() -> mock.fn()
  - vi.spyOn() -> spyOn() from bun:test
  - vi.mock() -> mock.module()
  - Remove vitest dependencies and config files
  - Update turbo.json with test pipeline
  - Fix packages without tests (biome, cli) to exit 0

- Enhance AGENTS.md with hierarchical documentation
  - Root AGENTS.md: comprehensive monorepo guide with Bun testing
  - packages/hydrogen/AGENTS.md: Hydrogen-specific patterns
  - packages/schema/AGENTS.md: Schema package specifics
  - packages/react/AGENTS.md: React bindings documentation
  - Add Core Testing Directive (80/20 rule, AAA, FIRST, TDD)

All 161 tests pass across 4 packages.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 4, 2026

⚠️ No Changeset found

Latest commit: 01e5ffa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@claude
Copy link
Copy Markdown

claude Bot commented Mar 4, 2026

Claude finished @paul-phan's task in 2m 9s —— View job


Code Review Summary

Overall: This is a well-executed migration from Vitest to Bun's native test runner with comprehensive documentation enhancements. The changes are clean, thorough, and ready to merge. All 161 tests pass, and the hierarchical AGENTS.md structure provides excellent package-specific guidance.

Issues

No blocking issues found. The migration is complete and correct.

Suggestions

💬 [packages/i18n/tests/client.test.ts:94-99] — Test coverage reduced
The original test verified that WeaverseI18nProvider accepts data with the correct shape by checking it doesn't throw when called with props. The new version only checks the component is a function with parameters. While testing React components in a non-React environment is challenging, consider either:

  • Keeping the original approach (calling the component directly with props)
  • Moving this test to a React-testing environment
  • Accepting the reduced coverage as documented in AGENTS.md's "Ignore Boilerplate" guidance

💬 [CLAUDE.md:1-29] — CLAUDE.md now a thin shim
The file went from 326 lines to 27 lines, consolidating everything into AGENTS.md. This is a positive change for maintainability, but verify that any external tooling or CI workflows that reference CLAUDE.md content still work correctly.

What's Good

  • Clean migration: All Vitest APIs correctly replaced with Bun equivalents (vi.fn()mock.fn(), vi.spyOn()spyOn(), vi.mock()mock.module())
  • Smart test fixes: Packages without tests (biome, cli) now exit 0 instead of failing with echo 'No tests'
  • Turbo pipeline: Test task properly configured with dependency on build
  • Documentation excellence: Root AGENTS.md provides comprehensive monorepo guide; package-specific AGENTS.md files (hydrogen, schema, react) offer targeted guidance
  • Core Testing Directive: New testing section in AGENTS.md articulates clear principles (80/20 rule, AAA pattern, FIRST principles)
  • Proper cleanup: Vitest config files and dependencies removed from all packages

Agent Fix Prompts

No fix prompts needed — all issues are minor suggestions.

…ck.fn(), consolidate CLAUDE.md

- Fix Quick Reference: bun x vitest run -> bun test
- Fix Tooling section: Vitest -> Bun native test runner
- Replace no-op arrow functions with mock.fn() in hydrogen test cache mock
- Consolidate CLAUDE.md to reference AGENTS.md as single source of truth
@paul-phan paul-phan requested review from hta218 and viethung26 March 4, 2026 12:18
@paul-phan paul-phan merged commit 2a28a7d into main Mar 5, 2026
8 checks passed
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