Files
effect/.patterns/testing-patterns.md
T
2026-04-13 11:33:01 +12:00

921 B

Testing Patterns - Effect Library

Testing Framework Selection

Use it.effect for Effect-based modules.

import { assert, describe, it } from "@effect/vitest"
import { Effect } from "effect"

// Use it.effect for Effect-based tests
it.effect("should work with Effects", () =>
  Effect.gen(function*() {
    const result = yield* someEffect
    assert.strictEqual(result, expectedValue)
  }))

Use regular it for pure TypeScript functions

import { describe, expect, it } from "@effect/vitest"

// For pure functions that don't return Effects
it("should work with pure functions", () => {
  const result = pureFunction(input)
  expect(result).toBe(expectedValue)
})

Testing Rules

  • Never use Effect.runSync in tests
  • Never use expect with it.effect. Use assert methods instead
  • Always use TestClock for time-dependent operations
  • Group Related Tests using describe