Package: effect
Module: TestClock
Executes the specified effect with the live Clock instead of the
TestClock.
Example (Running with the live clock)
import { Clock, Effect } from "effect"
import { TestClock } from "effect/testing"
const program = Effect.gen(function*() {
// Get the current test time (starts at epoch)
const testTime = yield* Clock.currentTimeMillis
console.log(testTime) // 0
// Get the actual system time using withLive
const realTime = yield* TestClock.withLive(Clock.currentTimeMillis)
console.log(realTime) // Actual system timestamp
// Advance test time
yield* TestClock.adjust("1 hour")
// Test time is now 1 hour ahead
const newTestTime = yield* Clock.currentTimeMillis
console.log(newTestTime) // 3600000 (1 hour in milliseconds)
})
Signature
declare const withLive: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
Since v4.0.0