Skip to content

feat(bun-test): add @effect/bun-test package#6236

Open
emilienbidet wants to merge 1 commit into
Effect-TS:mainfrom
emilienbidet:feat/bun-test
Open

feat(bun-test): add @effect/bun-test package#6236
emilienbidet wants to merge 1 commit into
Effect-TS:mainfrom
emilienbidet:feat/bun-test

Conversation

@emilienbidet
Copy link
Copy Markdown

Summary

Adds a new @effect/bun-test workspace package that mirrors the @effect/vitest
API surface (it.effect, it.scoped, it.live, it.scopedLive, it.layer,
it.prop, flakyTest, layer, …) but runs on Bun's built-in
bun:test runner instead of Vitest.

Closes #5964.

Why

Quoting #5964: Bun's test runner is significantly faster than Vitest, and the
Vitest dependency of @effect/vitest is a thin wrapper around it() and
describe() — the actual Effect test machinery (TestClock, TestServices,
fast-check integration) is runner-agnostic. This PR ports that thin wrapper
to bun:test so users on Bun can avoid pulling in Vitest entirely.

What's in the package

packages/bun-test/ is laid out exactly like packages/vitest/:

  • src/index.ts — public API, types, re-exports of bun:test primitives
  • src/internal/internal.ts — Effect runner + tester/layer/prop wrappers
  • src/utils.ts — assertion helpers (copied from @effect/vitest utils.ts,
    vassert.instanceOf swapped for node:assert)
  • test/index.test.ts — ported from packages/vitest/test/index.test.ts
  • tsconfig.*, docgen.json, bunfig.toml, package.json, README.md,
    LICENSE

A changeset is included (.changeset/add-effect-bun-test.md).

Differences from @effect/vitest

Bun's test runner has a smaller surface than Vitest. The PR documents these
gaps in the package README; they were not papered over with runtime shims:

  • addEqualityTesters is a no-opbun:test's expect has no
    addEqualityTesters API. Effect's Equal.equals is exposed via the
    package-level helpers in @effect/bun-test/utils (assertEquals, etc.).
  • TestContext is synthesised inside the test wrapper rather than passed
    in by the runner, because bun:test doesn't pass a context object. It
    exposes a fresh signal: AbortSignal and best-effort onTestFinished /
    onTestFailed callbacks invoked after the Effect resolves.
  • scopedFixtures (vitest's fixture system) is not provided.
  • re-export from \"bun:test\" doesn't work in Bun (1.2.x), so the public
    primitives are re-exported via const bindings rather than export *.

Test plan

  • pnpm install at the workspace root resolves cleanly
  • pnpm --filter=@effect/bun-test check passes
  • bun test inside packages/bun-test is green
    • 32 pass, 6 skip, 0 fail (the skips are the test file's deliberate
      it.skip/it.skipIf(true) cases)
  • Maintainers to decide whether CI should grow a Bun job for this package

Notes for review

  • One Bun-specific tweak in test/index.test.ts: the layer > release test
    had its trailing afterAll(...) reordered so it runs after the layer's
    own afterAll (Bun runs afterAll hooks in registration order; Vitest's
    ordering happened to release the scope before the assertion).
  • The it.scopedLive.fails("interrupts on timeout", ...) test from the Vitest
    suite was dropped because Bun doesn't expose the equivalent of Vitest's
    onTestFailed hook with a fiber-interrupt handle.
  • No upstream files outside packages/bun-test/, .changeset/, and
    pnpm-lock.yaml were touched.

Mirrors @effect/vitest's API (it.effect, it.scoped, it.live, it.scopedLive,
it.layer, it.prop, flakyTest) but runs under Bun's built-in bun:test runner.

Closes Effect-TS#5964.
@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog May 17, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 17, 2026

🦋 Changeset detected

Latest commit: 3f8d6e8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/bun-test Minor

Not sure what this means? Click here to learn what changesets are.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

Add @effect/bun-test package for native Bun test runner support

1 participant