Effect ts test integration with vitest
Skill kjuhwa/skills-hub/skills/testing/effect-ts-test-integration-with-vitest
Test effect-based services by composing layers with Vitest, using drain() instead of sleep for deterministic asyncFrom its SKILL.md
npx -y skills add kjuhwa/skills-hub --skill effect-ts-test-integration-with-vitestAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.5 KB, 445 tokens by cl100k_base, as published. Nobody here has run it
When to Apply
- You write tests for Effect.ts-based services with side effects (I/O, async, external services)
- You want tests to be deterministic and not flaky
- You're using Vitest as your test runner (not Jest)
- You need to stub external services (git, providers, filesystem)
Steps
- Define your service layer as
Layer.effect(TAG)that yields a{ method1, method2 }interface - Create test doubles (stubs) that implement the same interface but return fixed/controlled values
- In test, build a layer graph that includes test doubles instead of real implementations
- Use
Effect.gento compose the test effect - Instead of
sleep, useworker.drain()orstream.toArray()to wait for async work - Run effect via
Effect.runPromise()or Vitest's Effect integration - Assert state after all async milestones complete
Example
const mockGitCore = Layer.succeed(GitCore, {
executeGit: (cmd) => Effect.succeed({ stdout: '...' }),
getStatus: () => Effect.succeed({ isRepo: true })
})
const testEffect = Effect.gen(function*() {
const orchestration = yield* OrchestrationEngine
const worker = yield* checkpointReactor
yield* orchestration.dispatch({ type: 'thread.turn.start', ... })
yield* worker.drain() // wait for checkpoint work to finish
const checkpoints = yield* orchestration.getCheckpoints(...)
expect(checkpoints).toHaveLength(1)
})
const layers = Layer.compose(mockGitCore, OrchestrateLayer)
const result = yield* testEffect.pipe(Effect.provide(layers))
Counter / Caveats
- Layer composition order matters; dependencies must be available before use
- Test doubles can diverge from real implementations; keep in sync or use property-based tests
drain()only works for DrainableWorker; other async patterns needEffect.sleeporFuture- Large test suites with many layers can slow down test startup; consider shared layer fixtures
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.