Skip to content

index.ts

Since v4.0.0



Re-exports all named exports from the “vitest” module.

Signature

export * from "vitest"

Source

Since v4.0.0

Signature

type API = V.TestAPI<{}>

Source

Since v4.0.0

Source

Since v4.0.0

Signature

export interface TestFunction<A, E, R, TestArgs extends Array<any>> {
(...args: TestArgs): Effect.Effect<A, E, R>
}

Source

Since v4.0.0

Signature

export interface Test<R> {
<A, E>(name: string, self: TestFunction<A, E, R, [V.TestContext]>, timeout?: number | V.TestOptions): void
}

Source

Since v4.0.0

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
}

Source

Since v4.0.0

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
}

Source

Since v4.0.0

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
}
}

Source

Since v4.0.0

Signature

type Arbitraries =
| Array<Schema.Schema<any> | FC.Arbitrary<any>>
| { [K in string]: Schema.Schema<any> | FC.Arbitrary<any> }

Source

Since v4.0.0

Signature

declare const addEqualityTesters: () => void

Source

Since v4.0.0

Signature

declare const describeWrapped: (name: string, f: (it: Vitest.Methods) => void) => V.SuiteCollector

Source

Since v4.0.0

Signature

declare const effect: Vitest.Tester<Scope.Scope>

Source

Since v4.0.0

Signature

declare const flakyTest: <A, E, R>(
self: Effect.Effect<A, E, R | Scope.Scope>,
timeout?: Duration.Input
) => Effect.Effect<A, never, R>

Source

Since v4.0.0

Signature

declare const it: Vitest.Methods<never>

Source

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
}

Source

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>

Source

Since v4.0.0

Signature

declare const makeMethods: (it: V.TestAPI) => Vitest.Methods

Source

Since 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
}>
})
) => void

Source

Since v4.0.0