effect-testing

Write tests for Effect applications using @effect/vitest, TestClock, layers, and property-based testing.

3|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-testing-mpsuesser
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: effect-testing
Source: https://github.com/mpsuesser/opencode-effect-enforcer/tree/main/skills/effect-testing
Command: npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-testing-mpsuesser

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Testing Effect-based TypeScript code requires choosing the right runner, controlling time and services, and asserting on typed failures — mistakes here produce flaky or misleading tests. This Skill provides complete guidance for testing Effect applications with @effect/vitest and plain vitest. ## Core Features & Use Cases - Framework Selection: Distinguishes when to use @effect/vitest (Effect code, services, TestClock) versus standard vitest (pure functions, utilities). - Service and Layer Testing: Covers Effect.provide, Layer.mock, the layer helper for shared test layers, nested it.layer suites, and first-class controllable test services. - Time and Error Testing: Uses TestClock to advance time instantly, Effect.flip and Effect.exit for typed failure assertions, and Cause inspection for error types. - Property-Based and HTTP Mock Testing: Supports it.prop and it.effect.prop with Schema arbitraries, plus HTTP/SSE mock server patterns for testing real service layers end to end. - Use Case: When writing tests for a service with retries and delays, use it.effect with TestClock.adjust to verify retry behavior in milliseconds instead of waiting for real timeouts. ## Quick Start Ask the agent to write tests for your Effect service using @effect/vitest with TestClock and a mock layer.

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 vitest?▼

Use @effect/vitest and its it.effect function, which scopes the test and installs TestClock and TestConsole. Write assertions inside Effect.gen using the standard expect from vitest, and provide service dependencies with Effect.provide or the layer helper.

When should I use @effect/vitest vs plain vitest?▼

Use @effect/vitest for functions returning Effect, code using services and layers, TestClock-dependent operations, and STM. Use standard vitest for pure functions, data transformations, helpers, and type constructors with no Effect wrapper.

How do I test time-dependent Effect code without waiting?▼

Use TestClock from effect/testing inside it.effect. Fork the delayed effect with Effect.forkChild, then call TestClock.adjust with a duration like '5 seconds' to advance time instantly before joining the fiber and asserting the result.

How do I test expected failures in Effect?▼

Use Effect.flip to convert a failure channel into a success value you can assert on, or Effect.exit to capture the full Exit value. For typed errors, inspect the Cause with hasFails and findErrorOption to verify specific error instances.

Does @effect/vitest work with Vitest 3 or 4?▼

No. The @effect/vitest adapter requires a Vitest peer range of >=5.0.0 <6.0.0 and Node.js ^22.12.0, ^24.0.0, or >=26.0.0. Projects on Vitest 3 or 4 must migrate their test framework before installing the adapter.

How do I share a test layer across multiple Effect tests?▼

Use the layer function from @effect/vitest, passing your Layer and a callback receiving an it object. All it.effect tests inside share the memoized layer, and nested it.layer suites fork their own memo map while reusing parent allocations.