import * as Context from "@effect/data/Context" import type * as DefaultServices from "@effect/io/DefaultServices" import type * as Effect from "@effect/io/Effect" import * as core from "@effect/io/internal/core" import * as defaultServices from "@effect/io/internal/defaultServices" /** @internal */ export const LiveTypeId = Symbol.for("@effect/test/Live") /** @internal */ export type LiveTypeId = typeof LiveTypeId /** * The `Live` trait provides access to the "live" default Effect services from * within tests for workflows such as printing test results to the console or * timing out tests where it is necessary to access the real implementations of * these services. * * @internal */ export interface Live { readonly [LiveTypeId]: LiveTypeId provide(effect: Effect.Effect): Effect.Effect } /** @internal */ export const Live: Context.Tag = Context.Tag( Symbol.for("@effect/test/Live") ) /** @internal */ class LiveImpl implements Live { readonly [LiveTypeId]: LiveTypeId = LiveTypeId constructor(readonly services: Context.Context) {} provide(effect: Effect.Effect): Effect.Effect { return core.fiberRefLocallyWith( defaultServices.currentServices, Context.merge(this.services) )(effect) } } /** @internal */ export const make = (services: Context.Context): Live => new LiveImpl(services)