Skip to content

TestServices

34 exports Added in v2.0.0 Source

Other

annotate

Added in v2.0.0 Source

Accesses an Annotations instance in the context and appends the specified annotation to the annotation map.

Signature

declare function annotate<A>(key: TestAnnotation<A>, value: A): Effect<void>;

annotations

Added in v2.0.0 Source

Retrieves the Annotations service for this test.

Signature

declare function annotations(): Effect<TestAnnotations>;

Constructs a new Annotations service wrapped in a layer.

Signature

declare function annotationsLayer(): Layer<TestAnnotations>;

Retrieves the Annotations service for this test and uses it to run the specified workflow.

Signature

declare function annotationsWith<A, E, R>(
  f: (annotations: TestAnnotations) => Effect<A, E, R>,
): Effect<A, E, R>;

Signature

declare const currentServices: FiberRef.FiberRef<Context.Context<TestServices>>;

get

Added in v2.0.0 Source

Accesses an Annotations instance in the context and retrieves the annotation of the specified type, or its default value if there is none.

Signature

declare function get<A>(key: TestAnnotation<A>): Effect<A>;

live

Added in v2.0.0 Source

Retrieves the Live service for this test.

Signature

declare const live: Effect.Effect<Live.TestLive>;

liveLayer

Added in v2.0.0 Source

Constructs a new Live service wrapped in a layer.

Signature

declare function liveLayer(): Layer<TestLive, never, DefaultServices>;

liveServices

Added in v2.0.0 Source

The default Effect test services.

Signature

declare const liveServices: Context.Context<TestServices>;

liveWith

Added in v2.0.0 Source

Retrieves the Live service for this test and uses it to run the specified workflow.

Signature

declare function liveWith<A, E, R>(f: (live: TestLive) => Effect<A, E, R>): Effect<A, E, R>;

provideLive

Added in v2.0.0 Source

Provides a workflow with the "live" default Effect services.

Signature

declare function provideLive<A, E, R>(effect: Effect<A, E, R>): Effect<A, E, R>;

Runs a transformation function with the live default Effect services while ensuring that the workflow itself is run with the test services.

Signature

declare const provideWithLive: <A, E, R, A2, E2, R2>(f: (effect: Effect<A, E, R>) => Effect<A2, E2, R2>) => (self: Effect<A, E, R>) => Effect<A2, E | E2, R | R2> & <A, E, R, A2, E2, R2>(self: Effect<A, E, R>, f: (effect: Effect<A, E, R>) => Effect<A2, E2, R2>) => Effect<A2, E | E2, R | R2>

repeats

Added in v2.0.0 Source

The number of times to repeat tests to ensure they are stable.

Signature

declare const repeats: Effect.Effect<number>;

retries

Added in v2.0.0 Source

The number of times to retry flaky tests.

Signature

declare const retries: Effect.Effect<number>;

samples

Added in v2.0.0 Source

The number of sufficient samples to check for a random variable.

Signature

declare const samples: Effect.Effect<number>;

shrinks

Added in v2.0.0 Source

The maximum number of shrinkings to minimize large failures.

Signature

declare const shrinks: Effect.Effect<number>;

size

Added in v2.0.0 Source

Signature

declare const size: Effect.Effect<number>;

sized

Added in v2.0.0 Source

Retrieves the Sized service for this test.

Signature

declare const sized: Effect.Effect<Sized.TestSized>;

sizedLayer

Added in v2.0.0 Source

Signature

declare function sizedLayer(size: number): Layer<TestSized>;

sizedWith

Added in v2.0.0 Source

Retrieves the Sized service for this test and uses it to run the specified workflow.

Signature

declare function sizedWith<A, E, R>(f: (sized: TestSized) => Effect<A, E, R>): Effect<A, E, R>;

Returns the set of all fibers in this test.

Signature

declare function supervisedFibers(): Effect<SortedSet<RuntimeFiber<unknown, unknown>>>;

testConfig

Added in v2.0.0 Source

Retrieves the TestConfig service for this test.

Signature

declare const testConfig: Effect.Effect<TestConfig.TestConfig>;

Constructs a new TestConfig service with the specified settings.

Signature

declare function testConfigLayer(params: {
  readonly repeats: number;
  readonly retries: number;
  readonly samples: number;
  readonly shrinks: number;
}): Layer<TestConfig>;

Retrieves the TestConfig service for this test and uses it to run the specified workflow.

Signature

declare function testConfigWith<A, E, R>(
  f: (config: TestConfig) => Effect<A, E, R>,
): Effect<A, E, R>;

TestServices type

Added in v2.0.0 Source

Signature

type TestServices =
  | Annotations.TestAnnotations
  | Live.TestLive
  | Sized.TestSized
  | TestConfig.TestConfig;

Executes the specified workflow with the specified implementation of the annotations service.

Signature

declare const withAnnotations: (annotations: TestAnnotations) => <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R> & <A, E, R>(effect: Effect<A, E, R>, annotations: TestAnnotations) => Effect<A, E, R>

Sets the implementation of the annotations service to the specified value and restores it to its original value when the scope is closed.

Signature

declare function withAnnotationsScoped(annotations: TestAnnotations): Effect<void, never, Scope>;

withLive

Added in v2.0.0 Source

Executes the specified workflow with the specified implementation of the live service.

Signature

declare const withLive: (live: TestLive) => <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R> & <A, E, R>(effect: Effect<A, E, R>, live: TestLive) => Effect<A, E, R>

Sets the implementation of the live service to the specified value and restores it to its original value when the scope is closed.

Signature

declare function withLiveScoped(live: TestLive): Effect<void, never, Scope>;

withSize

Added in v2.0.0 Source

Signature

declare const withSize: (size: number) => <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R> & <A, E, R>(effect: Effect<A, E, R>, size: number) => Effect<A, E, R>

withSized

Added in v2.0.0 Source

Executes the specified workflow with the specified implementation of the sized service.

Signature

declare const withSized: (sized: TestSized) => <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R> & <A, E, R>(effect: Effect<A, E, R>, sized: TestSized) => Effect<A, E, R>

Sets the implementation of the sized service to the specified value and restores it to its original value when the scope is closed.

Signature

declare function withSizedScoped(sized: TestSized): Effect<void, never, Scope>;

Executes the specified workflow with the specified implementation of the config service.

Signature

declare const withTestConfig: (config: TestConfig) => <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R> & <A, E, R>(effect: Effect<A, E, R>, config: TestConfig) => Effect<A, E, R>

Sets the implementation of the config service to the specified value and restores it to its original value when the scope is closed.

Signature

declare function withTestConfigScoped(config: TestConfig): Effect<void, never, Scope>;