Skip to content

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

Open
emilienbidet wants to merge 2 commits into
Effect-TS:mainfrom
emilienbidet:feat/bun-test-v4
Open

feat(bun-test): add @effect/bun-test package#7521
emilienbidet wants to merge 2 commits into
Effect-TS:mainfrom
emilienbidet:feat/bun-test-v4

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, layer, it.prop, flakyTest, utils, …) but runs on Bun's built-in bun:test runner instead of Vitest.

This is the replacement for Effect-TS/effect-smol#2204, reopened here after the v4 codebase was merged back into this repository (as requested by @IMax153 in that thread). It addresses the same request as #5964 (and supersedes the v3 attempt in #5973). The code has been re-ported against the current main — notably the property-testing layer now uses effect/unstable/arbitrary/Arbitrary (Arbitrary.checkEffect, CheckOptions, Schema + Arbitrary mixed inputs) exactly like the current @effect/vitest, instead of the FastCheck API the effect-smol PR used.

What's in the package

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

  • src/index.ts — public API and types, re-exports of the bun:test primitives, plus a small node:assert-backed assert object covering the chai surface Effect suites use from Vitest
  • src/internal/internal.ts — Effect runner + tester/layer/prop wrappers (Effect.fnUntraced, Layer.buildWithMemoMap, Layer.forkMemoMapUnsafe for nested layers, Layer.mergeAll(TestConsole.layer, TestClock.layer()), Arbitrary.checkEffect)
  • src/utils.ts — the @effect/vitest/utils assertion helpers (vassert.instanceOf swapped for a plain instanceof check)
  • test/index.test.ts — ported from packages/vitest/test/index.test.ts
  • workspace wiring: a tsconfig.packages.json reference and tsconfig.tests.json path aliases; a changeset is included

Improvement over the effect-smol PR: timeouts interrupt fibers

Bun's own test timeout fails the test but cannot stop the Effect running behind it, so finalizers would never run. The wrapper now owns the timeout: when it fires, the synthesized test context's AbortSignal aborts, the fiber is interrupted via Effect.runPromise(effect, { signal }), and finalizers run — Bun keeps a slightly larger timeout as a backstop. This let the two timeout-interruption tests from the vitest suite (interrupts on timeout, interrupts property checking on timeout) be ported instead of dropped.

Differences from @effect/vitest (documented in the package README)

  • addEqualityTesters is a no-opbun:test's expect has no addEqualityTesters API.
  • TestContext is synthesized inside the test wrapper (signal, onTestFinished, onTestFailed), because bun:test doesn't pass a context object.
  • export * from "bun:test" doesn't work in Bun, so the public primitives are re-exported via const bindings.
  • it.skip.each is reimplemented (with %s-style title interpolation) since Bun doesn't chain those registrars.

Test plan

  • pnpm install at the workspace root resolves cleanly
  • pnpm --filter=@effect/bun-test check and build (tsc + babel) pass
  • pnpm check (repo-wide tsc -b) passes, including the swept-in test file
  • pnpm exec dprint check and pnpm exec oxlint pass
  • bun test inside packages/bun-test: 40 pass, 5 skip (deliberate skip/todo cases), 0 fail
  • Maintainers to decide whether CI should grow a Bun job for this package (the root vitest config's explicit project list is untouched, so the vitest run does not pick these tests up)

🤖 Generated with Claude Code

https://claude.ai/code/session_01TBYAaLaKUsUBsfGKV5jGpn

The @effect/vitest API (it.effect, it.live, layer, it.prop, flakyTest,
utils, assert) on Bun's native bun:test runner. Wrapper-managed timeouts
abort the synthesized test context's AbortSignal, so Effect fibers are
interrupted and their finalizers run on timeout, which Bun's own timeout
cannot do.

Replaces Effect-TS/effect-smol#2204 after the v4 migration back into this
repository; addresses Effect-TS#5964.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TBYAaLaKUsUBsfGKV5jGpn
@changeset-bot

changeset-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25b51ae

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 Patch

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

… order

deno check must not sweep packages/bun-test: the bun:test import and the
bun types reference inject Bun's global overrides (URL, URLSearchParams)
into the shared program, which breaks unrelated packages — same reason
packages/platform/bun is excluded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TBYAaLaKUsUBsfGKV5jGpn
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 33.76 KB 33.76 KB 0.00 KB (0.00%)
basic.ts 7.00 KB 7.00 KB 0.00 KB (0.00%)
batching.ts 9.87 KB 9.87 KB 0.00 KB (0.00%)
brand.ts 6.56 KB 6.56 KB 0.00 KB (0.00%)
cache.ts 10.74 KB 10.74 KB 0.00 KB (0.00%)
config.ts 21.45 KB 21.45 KB 0.00 KB (0.00%)
differ.ts 20.32 KB 20.32 KB 0.00 KB (0.00%)
http-client.ts 21.76 KB 21.76 KB 0.00 KB (0.00%)
logger.ts 10.94 KB 10.94 KB 0.00 KB (0.00%)
metric.ts 8.98 KB 8.98 KB 0.00 KB (0.00%)
optic.ts 6.73 KB 6.73 KB 0.00 KB (0.00%)
pubsub.ts 15.12 KB 15.12 KB 0.00 KB (0.00%)
queue.ts 11.84 KB 11.84 KB 0.00 KB (0.00%)
schedule.ts 10.86 KB 10.86 KB 0.00 KB (0.00%)
schema-binary.ts 39.42 KB 39.42 KB 0.00 KB (0.00%)
schema-class.ts 20.07 KB 20.07 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 31.02 KB 31.02 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.21 KB 26.21 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.66 KB 13.66 KB 0.00 KB (0.00%)
schema-string.ts 11.18 KB 11.18 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.47 KB 15.47 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 33.31 KB 33.31 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.51 KB 24.51 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.29 KB 19.29 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.42 KB 19.42 KB 0.00 KB (0.00%)
schema-toFormatter.ts 19.51 KB 19.51 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 23.45 KB 23.45 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.56 KB 19.56 KB 0.00 KB (0.00%)
schema.ts 19.28 KB 19.28 KB 0.00 KB (0.00%)
stm.ts 12.74 KB 12.74 KB 0.00 KB (0.00%)
stream.ts 9.83 KB 9.83 KB 0.00 KB (0.00%)

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

Labels

4.0 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant