fix: preserve Effect equality and scoped test lifetimes - #5
Merged
Nsttt merged 1 commit intoSep 19, 2026
Merged
Conversation
- addEqualityTesters only delegates to Equal.equals when both values implement Equal, so plain objects and asymmetric matchers keep Rstest's native behavior. - Timed-out Effect tests register an onTestFinished barrier that awaits fiber settlement and scoped finalizers before later sequential tests and suite-layer release, without changing runner outcomes. - Layer suites track the setup fiber and interrupt it before closing the scope, so a timed-out or early-failed beforeAll cannot outlive teardown or leak resources acquired before the failure. Ported from ScriptedAlchemy/effect-rstest#4 with runner-conformance fixtures for test and layer lifetimes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Nsttt
approved these changes
Sep 19, 2026
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.
ScriptedAlchemy/effect-rstest#4 (origin of these fixes) | TechsioCZ/ontos#507 (consumer currently carrying them as a pnpm patch)
Why the change
Timed-out Effect tests and layer setups keep running after Rstest has moved on, and
addEqualityTesters()breaks asymmetric matchers, so consumers patch the published package; this PR lands those fixes upstream so the patch can go away.Special things to note
afterEachhooks run beforeonTestFinishedand are outside the guarantee. Both are documented in the README.test/fixtures/run-fixture.ts) and assert the JSON report verbatim, including runner error strings likebeforeAll hook timed out in 100ms. A future@rstest/corewording change will need those expectations updated.Effect.asVoidat the test boundary already exist here, so only the three behavioral fixes from the upstream PR are ported.Change outline
Everything lives in
src/internal/internal.ts; the rest is tests and docs.Equality: with
||, a plain object versus anEqualvalue returned a hardfalse, soexpect.objectContainingnever got a turn.Test settlement: Rstest reports a timeout and immediately starts the next test; the fiber and its finalizers were still running.
Layer teardown: suite hooks have no
AbortSignal, so abeforeAllthat exceeded its timeout kept building the layer whileafterAllclosed the scope underneath it.How the lifetime tests verify it:
🤖 Generated with Claude Code