index.ts
index.ts overview
Section titled “index.ts overview”Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”“vitest” (namespace export)
Section titled ““vitest” (namespace export)”Re-exports all named exports from the “vitest” module.
Signature
export * from "vitest"Since v4.0.0
API (type alias)
Section titled “API (type alias)”Signature
type API = V.TestAPI<{}>Since v4.0.0
Vitest (namespace)
Section titled “Vitest (namespace)”Since v4.0.0
TestFunction (interface)
Section titled “TestFunction (interface)”Signature
export interface TestFunction<A, E, R, TestArgs extends Array<any>> { (...args: TestArgs): Effect.Effect<A, E, R>}Since v4.0.0
Test (interface)
Section titled “Test (interface)”Signature
export interface Test<R> { <A, E>(name: string, self: TestFunction<A, E, R, [V.TestContext]>, timeout?: number | V.TestOptions): void}Since v4.0.0
Tester (interface)
Section titled “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 fails: Vitest.Test<R>
/** * @since 4.0.0 */ prop: <const Arbs extends Arbitraries, A, E>( name: string, arbitraries: Arbs, self: TestFunction< A, E, R, [ { [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T : never }, V.TestContext ] >, timeout?: | number | (V.TestOptions & { fastCheck?: FC.Parameters<{ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T : never }> }) ) => void}Since v4.0.0
MethodsNonLive (interface)
Section titled “MethodsNonLive (interface)”Signature
export interface MethodsNonLive<R = never> extends API { readonly effect: Vitest.Tester<R | Scope.Scope> readonly flakyTest: <A, E, R2>( self: Effect.Effect<A, E, R2 | Scope.Scope>, timeout?: Duration.Input ) => Effect.Effect<A, never, R2> readonly layer: <R2, E>( layer: Layer.Layer<R2, E, R>, options?: { readonly timeout?: Duration.Input } ) => { (f: (it: Vitest.MethodsNonLive<R | R2>) => void): void (name: string, f: (it: Vitest.MethodsNonLive<R | R2>) => void): void }
/** * @since 4.0.0 */ readonly prop: <const Arbs extends Arbitraries>( name: string, arbitraries: Arbs, self: ( properties: { [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T : never }, ctx: V.TestContext ) => void, timeout?: | number | (V.TestOptions & { fastCheck?: FC.Parameters<{ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T : never }> }) ) => void}Since v4.0.0
Methods (interface)
Section titled “Methods (interface)”Signature
export interface Methods<R = never> extends MethodsNonLive<R> { readonly live: Vitest.Tester<Scope.Scope | R> readonly layer: <R2, E>( layer: Layer.Layer<R2, E, R>, options?: { readonly memoMap?: Layer.MemoMap readonly timeout?: Duration.Input readonly excludeTestServices?: boolean } ) => { (f: (it: Vitest.MethodsNonLive<R | R2>) => void): void (name: string, f: (it: Vitest.MethodsNonLive<R | R2>) => void): void }}Since v4.0.0
Arbitraries (type alias)
Section titled “Arbitraries (type alias)”Signature
type Arbitraries = | Array<Schema.Schema<any> | FC.Arbitrary<any>> | { [K in string]: Schema.Schema<any> | FC.Arbitrary<any> }Since v4.0.0
addEqualityTesters
Section titled “addEqualityTesters”Signature
declare const addEqualityTesters: () => voidSince v4.0.0
describeWrapped
Section titled “describeWrapped”Signature
declare const describeWrapped: (name: string, f: (it: Vitest.Methods) => void) => V.SuiteCollectorSince v4.0.0
effect
Section titled “effect”Signature
declare const effect: Vitest.Tester<Scope.Scope>Since v4.0.0
flakyTest
Section titled “flakyTest”Signature
declare const flakyTest: <A, E, R>( self: Effect.Effect<A, E, R | Scope.Scope>, timeout?: Duration.Input) => Effect.Effect<A, never, R>Since v4.0.0
Signature
declare const it: Vitest.Methods<never>Since v4.0.0
Share a Layer between multiple tests, optionally wrapping
the tests in a describe block if a name is provided.
Signature
declare const layer: <R, E>( layer_: Layer.Layer<R, E>, options?: { readonly memoMap?: Layer.MemoMap readonly timeout?: Duration.Input readonly excludeTestServices?: boolean }) => { (f: (it: Vitest.MethodsNonLive<R>) => void): void (name: string, f: (it: Vitest.MethodsNonLive<R>) => void): void}Since v4.0.0
import { expect, layer } from "@effect/vitest"import { Effect, Layer, Context } from "effect"
class Foo extends Context.Service("Foo")<Foo, "foo">() { static Live = Layer.succeed(Foo, "foo")}
class Bar extends Context.Service("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") }) ) })})Signature
declare const live: Vitest.Tester<Scope.Scope>Since v4.0.0
makeMethods
Section titled “makeMethods”Signature
declare const makeMethods: (it: V.TestAPI) => Vitest.MethodsSince v4.0.0
Signature
declare const prop: <const Arbs extends Vitest.Arbitraries>( name: string, arbitraries: Arbs, self: ( properties: { [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T : never }, ctx: V.TestContext ) => void, timeout?: | number | (V.TestOptions & { fastCheck?: FC.Parameters<{ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T : never }> })) => voidSince v4.0.0