index overview
Added in v1.0.0
Table of contents
exports
From “vitest”
Re-exports all named exports from the “vitest” module.
Signature
export * from "vitest"
Added in v1.0.0
utils
API (type alias)
Signature
export type API = V.TestAPI<{}>
Added in v1.0.0
Vitest (namespace)
Added in v1.0.0
Methods (interface)
Signature
export interface Methods<R = never> extends API {
readonly effect: Vitest.Tester<TestServices.TestServices | R>
readonly live: Vitest.Tester<R>
readonly flakyTest: <A, E, R2>(
self: Effect.Effect<A, E, R2>,
timeout?: Duration.DurationInput
) => Effect.Effect<A, never, R2>
readonly scoped: Vitest.Tester<TestServices.TestServices | Scope.Scope | R>
readonly scopedLive: Vitest.Tester<Scope.Scope | R>
readonly layer: <R2, E>(
layer: Layer.Layer<R2, E, R>,
options?: {
readonly timeout?: Duration.DurationInput
}
) => {
(f: (it: Vitest.Methods<R | R2>) => void): void
(name: string, f: (it: Vitest.Methods<R | R2>) => void): void
}
/**
* @since 1.0.0
*/
readonly prop: <const S extends SchemaObj>(
name: string,
schemas: S,
self: (
schemas: { [K in keyof S]: Schema.Schema.Type<S[K]> },
ctx: V.TaskContext<V.RunnerTestCase<{}>> & V.TestContext
) => void,
timeout?: number | V.TestOptions
) => void
}
Added in v1.0.0
Test (interface)
Signature
export interface Test<R> {
<A, E>(
name: string,
self: TestFunction<A, E, R, [V.TaskContext<V.RunnerTestCase<{}>> & V.TestContext]>,
timeout?: number | V.TestOptions
): void
}
Added in v1.0.0
TestFunction (interface)
Signature
export interface TestFunction<A, E, R, TestArgs extends Array<any>> {
(...args: TestArgs): Effect.Effect<A, E, R>
}
Added in v1.0.0
Tester (interface)
Signature
export interface Tester<R> extends Vitest.Test<R> {
skip: Vitest.Test<R>
skipIf: (condition: unknown) => Vitest.Test<R>
runIf: (condition: unknown) => Vitest.Test<R>
only: Vitest.Test<R>
each: <T>(
cases: ReadonlyArray<T>
) => <A, E>(name: string, self: TestFunction<A, E, R, Array<T>>, timeout?: number | V.TestOptions) => void
/**
* @since 1.0.0
*/
prop: <const S extends SchemaObj, A, E>(
name: string,
schemas: S,
self: TestFunction<
A,
E,
R,
[{ [K in keyof S]: Schema.Schema.Type<S[K]> }, V.TaskContext<V.RunnerTestCase<{}>> & V.TestContext]
>,
timeout?: number | V.TestOptions
) => void
}
Added in v1.0.0
SchemaObj (type alias)
Signature
export type SchemaObj = Array<Schema.Schema.Any> | { [K in string]: Schema.Schema.Any }
Added in v1.0.0
addEqualityTesters
Signature
export declare const addEqualityTesters: () => void
Added in v1.0.0
effect
Signature
export declare const effect: Vitest.Tester<TestServices.TestServices>
Added in v1.0.0
flakyTest
Signature
export declare const flakyTest: <A, E, R>(self: Effect.Effect<A, E, R>, timeout?: any) => Effect.Effect<A, never, R>
Added in v1.0.0
it
Signature
export declare const it: Vitest.Methods<never>
Added in v1.0.0
layer
Share a Layer
between multiple tests, optionally wrapping the tests in a describe
block if a name is provided.
Signature
export declare const layer: <R, E>(
layer_: Layer.Layer<R, E>,
options?: { readonly memoMap?: Layer.MemoMap; readonly timeout?: Duration.DurationInput }
) => { (f: (it: Vitest.Methods<R>) => void): void; (name: string, f: (it: Vitest.Methods<R>) => void): void }
Added in v1.0.0
import { expect, layer } from "@effect/vitest"
import { Context, Effect, Layer } from "effect"
class Foo extends Context.Tag("Foo")<Foo, "foo">() {
static Live = Layer.succeed(Foo, "foo")
}
class Bar extends Context.Tag("Bar")<Bar, "bar">() {
static Live = Layer.effect(
Bar,
Effect.map(Foo, () => "bar" as const)
)
}
layer(Foo.Live)("layer", (it) => {
it.effect("adds context", () =>
Effect.gen(function* () {
const foo = yield* Foo
expect(foo).toEqual("foo")
})
)
it.layer(Bar.Live)("nested", (it) => {
it.effect("adds context", () =>
Effect.gen(function* () {
const foo = yield* Foo
const bar = yield* Bar
expect(foo).toEqual("foo")
expect(bar).toEqual("bar")
})
)
})
})
live
Signature
export declare const live: Vitest.Tester<never>
Added in v1.0.0
prop
Signature
export declare const prop: <const S extends Vitest.SchemaObj>(
name: string,
schemas: S,
self: (
schemas: { [K in keyof S]: Schema.Schema.Type<S[K]> },
ctx: V.TaskContext<V.RunnerTestCase<{}>> & V.TestContext
) => void,
timeout?: number | V.TestOptions
) => void
Added in v1.0.0
scoped
Signature
export declare const scoped: Vitest.Tester<any>
Added in v1.0.0
scopedLive
Signature
export declare const scopedLive: Vitest.Tester<Scope.Scope>
Added in v1.0.0