mirror of
https://github.com/Effect-TS/effect.git
synced 2026-11-16 09:57:46 +08:00
921 B
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