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