feat(bun-test): add @effect/bun-test package - #7521
Open
emilienbidet wants to merge 2 commits into
Open
Conversation
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 detectedLatest commit: 25b51ae The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This was referenced Aug 29, 2026
… 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
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
@effect/bun-testworkspace package that mirrors the@effect/vitestAPI surface (it.effect,it.live,layer,it.prop,flakyTest,utils, …) but runs on Bun's built-inbun:testrunner 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 useseffect/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/mirrorspackages/vitest/:src/index.ts— public API and types, re-exports of thebun:testprimitives, plus a smallnode:assert-backedassertobject covering the chai surface Effect suites use from Vitestsrc/internal/internal.ts— Effect runner + tester/layer/prop wrappers (Effect.fnUntraced,Layer.buildWithMemoMap,Layer.forkMemoMapUnsafefor nested layers,Layer.mergeAll(TestConsole.layer, TestClock.layer()),Arbitrary.checkEffect)src/utils.ts— the@effect/vitest/utilsassertion helpers (vassert.instanceOfswapped for a plaininstanceofcheck)test/index.test.ts— ported frompackages/vitest/test/index.test.tstsconfig.packages.jsonreference andtsconfig.tests.jsonpath aliases; a changeset is includedImprovement 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
AbortSignalaborts, the fiber is interrupted viaEffect.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)addEqualityTestersis a no-op —bun:test'sexpecthas noaddEqualityTestersAPI.TestContextis synthesized inside the test wrapper (signal,onTestFinished,onTestFailed), becausebun:testdoesn't pass a context object.export * from "bun:test"doesn't work in Bun, so the public primitives are re-exported viaconstbindings.it.skip.eachis reimplemented (with%s-style title interpolation) since Bun doesn't chain those registrars.Test plan
pnpm installat the workspace root resolves cleanlypnpm --filter=@effect/bun-test checkandbuild(tsc + babel) passpnpm check(repo-widetsc -b) passes, including the swept-in test filepnpm exec dprint checkandpnpm exec oxlintpassbun testinsidepackages/bun-test: 40 pass, 5 skip (deliberate skip/todo cases), 0 fail🤖 Generated with Claude Code
https://claude.ai/code/session_01TBYAaLaKUsUBsfGKV5jGpn