effect-testing

Write tests for Effect v4 applications using @effect/vitest and vitest.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-testing-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-testing
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-testing
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-testing-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @effect/vitest, vitest, effect.

What problem does it solve? Testing Effect-based TypeScript code requires choosing the right framework, test variant, and layer setup, and mistakes like misusing TestClock cause hangs and flaky integration tests. This Skill provides concrete patterns for testing Effect services, layers, time-dependent effects, errors, and HTTP integrations correctly. ## Core Features & Use Cases - Framework and Variant Selection: Distinguishes when to use @effect/vitest versus plain vitest, and when to use it.live versus it.effect with TestClock. - Service, Layer, and Error Testing: Covers Layer.mock, shared layer fixtures, Effect.flip and Effect.exit for failure assertions, and property-based testing with FastCheck and Schema arbitraries. - HTTP Mock Server Testing: Provides typed Step ADTs, SSE streaming responses, and Deferred-based request counting for deterministic integration tests without polling. - Use Case: When writing tests for an Effect service that calls an external LLM API over SSE, use the mock server pattern with it.live to verify serialization, retries, and streaming behavior end to end. ## Quick Start Write tests for my Effect service using @effect/vitest with a mock HTTP server and proper layer setup.

Frequently Asked Questions about effect-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test Effect code with @effect/vitest?

Use it.effect or it.live from @effect/vitest to run Effect-returning tests directly with yield* inside Effect.gen. Provide dependencies with Effect.provide and layers, and assert with standard vitest expect or utilities like assertSome and assertSuccess from @effect/vitest/utils.

When should I use it.live vs it.effect in @effect/vitest?

Use it.live as the default for tests touching services, databases, HTTP, or filesystems, since it uses real clock and random services. Reserve it.effect with TestClock only for tests that explicitly simulate time advancement, because TestClock causes hangs in integration tests.

How do I test expected errors in Effect?

Use Effect.flip to convert a failure into a success value you can assert on, or Effect.exit to capture the full Exit and inspect the Cause. In Effect v4, use Cause.hasFails and Cause.findErrorOption to check failure types.

Can I use Effect testing with bun:test instead of vitest?

Yes, but @effect/vitest helpers are unavailable, so build a custom harness using Effect.runPromise with Layer.provideMerge to supply TestClock and TestConsole layers. As of beta.70, TestClock.layer works with runPromise without an ambient Scope.

Why do my Effect integration tests hang with TestClock?

TestClock intercepts time-dependent operations like Effect.sleep, so real I/O combined with the test clock never advances and the test hangs. Switch those tests to it.live or exclude test services, keeping TestClock only for explicit time-simulation tests.

How do I mock HTTP services in Effect tests?

Prefer an HTTP mock server over service fakes: define a TestServer service with semantic helpers, implement it with Layer.effect and NodeHttpServer on port 0, and use Deferred-based request counting for synchronization. This tests serialization, status codes, and SSE framing through the real service layer.