(
layer_: Layer.Layer<R, E>,
options?: {
readonly memoMap?: Layer.MemoMap
readonly timeout?: Duration.DurationInput
readonly excludeTestServices?: ExcludeTestServices
}
)
| 187 | |
| 188 | /** @internal */ |
| 189 | export const layer = <R, E, const ExcludeTestServices extends boolean = false>( |
| 190 | layer_: Layer.Layer<R, E>, |
| 191 | options?: { |
| 192 | readonly memoMap?: Layer.MemoMap |
| 193 | readonly timeout?: Duration.DurationInput |
| 194 | readonly excludeTestServices?: ExcludeTestServices |
| 195 | } |
| 196 | ): { |
| 197 | (f: (it: Vitest.Vitest.MethodsNonLive<R, ExcludeTestServices>) => void): void |
| 198 | ( |
| 199 | name: string, |
| 200 | f: (it: Vitest.Vitest.MethodsNonLive<R, ExcludeTestServices>) => void |
| 201 | ): void |
| 202 | } => |
| 203 | ( |
| 204 | ...args: [ |
| 205 | name: string, |
| 206 | f: ( |
| 207 | it: Vitest.Vitest.MethodsNonLive<R, ExcludeTestServices> |
| 208 | ) => void |
| 209 | ] | [ |
| 210 | f: (it: Vitest.Vitest.MethodsNonLive<R, ExcludeTestServices>) => void |
| 211 | ] |
| 212 | ) => { |
| 213 | const excludeTestServices = options?.excludeTestServices ?? false |
| 214 | const withTestEnv = excludeTestServices |
| 215 | ? layer_ as Layer.Layer<R | TestServices.TestServices, E> |
| 216 | : Layer.provideMerge(layer_, TestEnv) |
| 217 | const memoMap = options?.memoMap ?? Effect.runSync(Layer.makeMemoMap) |
| 218 | const scope = Effect.runSync(Scope.make()) |
| 219 | const runtimeEffect = Layer.toRuntimeWithMemoMap(withTestEnv, memoMap).pipe( |
| 220 | Scope.extend(scope), |
| 221 | Effect.orDie, |
| 222 | Effect.cached, |
| 223 | Effect.runSync |
| 224 | ) |
| 225 | |
| 226 | const makeIt = (it: Vitest.API): Vitest.Vitest.MethodsNonLive<R, ExcludeTestServices> => |
| 227 | Object.assign(it, { |
| 228 | effect: makeTester<TestServices.TestServices | R>( |
| 229 | (effect) => Effect.flatMap(runtimeEffect, (runtime) => effect.pipe(Effect.provide(runtime))), |
| 230 | it |
| 231 | ), |
| 232 | |
| 233 | prop, |
| 234 | |
| 235 | scoped: makeTester<TestServices.TestServices | Scope.Scope | R>( |
| 236 | (effect) => |
| 237 | Effect.flatMap(runtimeEffect, (runtime) => |
| 238 | effect.pipe( |
| 239 | Effect.scoped, |
| 240 | Effect.provide(runtime) |
| 241 | )), |
| 242 | it |
| 243 | ), |
| 244 | flakyTest, |
| 245 | layer<R2, E2>(nestedLayer: Layer.Layer<R2, E2, R>, options?: { |
| 246 | readonly timeout?: Duration.DurationInput |
no test coverage detected