effect-concurrency-testing
Installation
SKILL.md
Effect Concurrency Testing Skill
This skill provides patterns for testing Effect's concurrency primitives: fibers, latches, deferreds, PubSub, SubscriptionRef, and streams.
Core Principles
CRITICAL: Choose the correct coordination primitive based on what you need to synchronize.
| Need | Use |
|---|---|
| Simple fiber yield | Effect.yieldNow |
| Wait for subscriber ready | Deferred.make() + Deferred.await |
| Wait for stream element | Effect.makeLatch() + Stream.tap(() => latch.open) |
| Passive subscription registration | explicit readiness signal if possible; otherwise a tiny one-tick yield/sleep fallback |
| Time-dependent behavior | TestClock.adjust |
| Verify events published | PubSub.subscribe + PubSub.takeAll |
| Check fiber status | fiber.unsafePoll() |
For Stream.fromPubSub subscription registration, prefer an explicit readiness signal when you control the stream. If the API offers no readiness hook and you only need registration to settle before publishing, a tiny Effect.yieldNow() or very short sleep is an acceptable last resort. Avoid broad polling or arbitrary delays.