Skip to content

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

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

feat(bun-test): add @effect/bun-test package#2204
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.live, it.layer, it.prop, flakyTest,
layer, …) but runs on Bun's built-in
bun:test runner instead of Vitest.

Companion PR to Effect-TS/effect#6236; addresses the same request as
Effect-TS/effect#5964.

Why

Quoting Effect-TS/effect#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,
TestConsole, fast-check integration) is runner-agnostic. This PR ports that
thin wrapper to bun:test for the v4 line in effect-smol.

What's in the package

packages/bun-test/ mirrors packages/vitest/:

  • src/index.ts — public API, types, re-exports of bun:test primitives
  • src/internal/internal.ts — Effect runner + tester/layer/prop wrappers
    (uses Effect.fnUntraced, Layer.buildWithMemoMap, Layer.mergeAll(TestConsole.layer, TestClock.layer())
    to match the v4 vitest package shape)
  • 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.json, 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.
  • TestContext is synthesised inside the test wrapper rather than passed
    in by the runner, because bun:test doesn't pass a context object.
  • 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
    • 24 pass, 4 skip, 0 fail
  • Maintainers to decide whether CI should grow a Bun job for this package

Notes for review

  • 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).
  • The it.live.fails("interrupts on timeout", ...) test from the vitest suite
    was dropped because Bun has no fiber-interrupt-on-failure hook equivalent.
  • No upstream files outside packages/bun-test/, .changeset/, and
    pnpm-lock.yaml were touched.

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

Closes Effect-TS/effect#5964.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 17, 2026

🦋 Changeset detected

Latest commit: 60247dc

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

This PR includes changesets to release 28 packages
Name Type
@effect/bun-test Major
effect Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/vitest Major
@effect/ai-anthropic Major
@effect/ai-openai-compat Major
@effect/ai-openai Major
@effect/ai-openrouter Major
@effect/atom-react Major
@effect/atom-solid Major
@effect/atom-vue Major
@effect/sql-clickhouse Major
@effect/sql-d1 Major
@effect/sql-libsql Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-pglite Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-do Major
@effect/sql-sqlite-node Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/openapi-generator Major

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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant