feat(bun-test): add @effect/bun-test package#6236
Open
emilienbidet wants to merge 1 commit into
Open
Conversation
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.
🦋 Changeset detectedLatest commit: 3f8d6e8 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 |
4 tasks
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.scoped,it.live,it.scopedLive,it.layer,it.prop,flakyTest,layer, …) but runs on Bun's built-inbun:testrunner instead of Vitest.Closes #5964.
Why
Quoting #5964: Bun's test runner is significantly faster than Vitest, and the
Vitest dependency of
@effect/vitestis a thin wrapper aroundit()anddescribe()— the actual Effect test machinery (TestClock, TestServices,fast-check integration) is runner-agnostic. This PR ports that thin wrapper
to
bun:testso users on Bun can avoid pulling in Vitest entirely.What's in the package
packages/bun-test/is laid out exactly likepackages/vitest/:src/index.ts— public API, types, re-exports ofbun:testprimitivessrc/internal/internal.ts— Effect runner + tester/layer/prop wrapperssrc/utils.ts— assertion helpers (copied from@effect/vitestutils.ts,vassert.instanceOfswapped fornode:assert)test/index.test.ts— ported frompackages/vitest/test/index.test.tstsconfig.*,docgen.json,bunfig.toml,package.json,README.md,LICENSEA changeset is included (
.changeset/add-effect-bun-test.md).Differences from
@effect/vitestBun'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:
addEqualityTestersis a no-op —bun:test'sexpecthas noaddEqualityTestersAPI. Effect'sEqual.equalsis exposed via thepackage-level helpers in
@effect/bun-test/utils(assertEquals, etc.).TestContextis synthesised inside the test wrapper rather than passedin by the runner, because
bun:testdoesn't pass a context object. Itexposes a fresh
signal: AbortSignaland best-effortonTestFinished/onTestFailedcallbacks 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 publicprimitives are re-exported via
constbindings rather thanexport *.Test plan
pnpm installat the workspace root resolves cleanlypnpm --filter=@effect/bun-test checkpassesbun testinsidepackages/bun-testis greenit.skip/it.skipIf(true)cases)Notes for review
test/index.test.ts: thelayer > releasetesthad its trailing
afterAll(...)reordered so it runs after the layer'sown
afterAll(Bun runsafterAllhooks in registration order; Vitest'sordering happened to release the scope before the assertion).
it.scopedLive.fails("interrupts on timeout", ...)test from the Vitestsuite was dropped because Bun doesn't expose the equivalent of Vitest's
onTestFailedhook with a fiber-interrupt handle.packages/bun-test/,.changeset/, andpnpm-lock.yamlwere touched.