Package: effect
Module: TestClock
Retrieves the TestClock service for this test and uses it to run the
specified workflow.
Example (Accessing the test clock)
import { Effect } from "effect"
import { TestClock } from "effect/testing"
const program = Effect.gen(function*() {
// Use testClockWith to access the TestClock instance
const currentTime = yield* TestClock.testClockWith((testClock) =>
Effect.succeed(testClock.currentTimeMillisUnsafe())
)
// Adjust time using the TestClock instance
yield* TestClock.testClockWith((testClock) => testClock.adjust("2 hours"))
console.log(currentTime) // Initial time
})
Signature
declare const testClockWith: <A, E, R>(f: (testClock: TestClock) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
Since v2.0.0