agentsclimarketplace

Effect ts test integration with vitest

Skill kjuhwa/skills-hub/skills/testing/effect-ts-test-integration-with-vitest

Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.

Install
npx -y skills add kjuhwa/skills-hub --skill effect-ts-test-integration-with-vitest

Assembled 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.

What its author says it does

Copied from the file, not written here

Test effect-based services by composing layers with Vitest, using drain() instead of sleep for deterministic async

SKILL.md

2.5 KB, 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

  1. Define your service layer as Layer.effect(TAG) that yields a { method1, method2 } interface
  2. Create test doubles (stubs) that implement the same interface but return fixed/controlled values
  3. In test, build a layer graph that includes test doubles instead of real implementations
  4. Use Effect.gen to compose the test effect
  5. Instead of sleep, use worker.drain() or stream.toArray() to wait for async work
  6. Run effect via Effect.runPromise() or Vitest's Effect integration
  7. 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 need Effect.sleep or Future
  • Large test suites with many layers can slow down test startup; consider shared layer fixtures

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.