Thanks to visit codestin.com
Credit goes to effect-ts.github.io

Skip to main content Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

index.ts overview

Since v1.0.0


Exports Grouped by Category


utils

“vitest” (namespace export)

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

Signature

export * from "vitest"

Source

Since v1.0.0

API (type alias)

Signature

type API = { scopedFixtures: V.TestAPI<{}>["scoped"] } & {
  [K in keyof V.TestAPI<{}>]: K extends "scoped" ? unknown : V.TestAPI<{}>[K]
} & TestCollectorCallable

Source

Since v1.0.0

Vitest (namespace)

Source

Since v1.0.0

TestFunction (interface)

Signature

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

Source

Since v1.0.0

Test (interface)

Signature

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

Source

Since 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
  fails: Vitest.Test<R>

  /**
   * @since 1.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 : Schema.Schema.Type<Arbs[K]> }, V.TestContext]
    >,
    timeout?:
      | number
      | (V.TestOptions & {
          fastCheck?: FC.Parameters<{
            [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
          }>
        })
  ) => void
}

Source

Since v1.0.0

MethodsNonLive (interface)

Signature

export interface MethodsNonLive<R = never, ExcludeTestServices extends boolean = false> extends API {
  readonly effect: Vitest.Tester<(ExcludeTestServices extends true ? never : TestServices.TestServices) | R>
  readonly flakyTest: <A, E, R2>(
    self: Effect.Effect<A, E, R2>,
    timeout?: Duration.DurationInput
  ) => Effect.Effect<A, never, R2>
  readonly scoped: Vitest.Tester<
    (ExcludeTestServices extends true ? never : TestServices.TestServices) | Scope.Scope | R
  >
  readonly layer: <R2, E>(
    layer: Layer.Layer<R2, E, R>,
    options?: {
      readonly timeout?: Duration.DurationInput
    }
  ) => {
    (f: (it: Vitest.MethodsNonLive<R | R2, ExcludeTestServices>) => void): void
    (name: string, f: (it: Vitest.MethodsNonLive<R | R2, ExcludeTestServices>) => void): void
  }

  /**
   * @since 1.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 : Schema.Schema.Type<Arbs[K]> },
      ctx: V.TestContext
    ) => void,
    timeout?:
      | number
      | (V.TestOptions & {
          fastCheck?: FC.Parameters<{
            [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
          }>
        })
  ) => void
}

Source

Since v1.0.0

Methods (interface)

Signature

export interface Methods<R = never> extends MethodsNonLive<R> {
  readonly live: Vitest.Tester<R>
  readonly scopedLive: Vitest.Tester<Scope.Scope | R>
}

Source

Since v1.0.0

Arbitraries (type alias)

Signature

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

Source

Since v1.0.0

addEqualityTesters

Signature

declare const addEqualityTesters: () => void

Source

Since v1.0.0

describeWrapped

Signature

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

Source

Since v1.0.0

effect

Signature

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

Source

Since v1.0.0

flakyTest

Signature

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

Source

Since v1.0.0

it

Signature

declare const it: Vitest.Methods<never>

Source

Since v1.0.0

layer

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, const ExcludeTestServices extends boolean = false>(
  layer_: Layer.Layer<R, E>,
  options?: {
    readonly memoMap?: Layer.MemoMap
    readonly timeout?: Duration.DurationInput
    readonly excludeTestServices?: ExcludeTestServices
  }
) => {
  (f: (it: Vitest.MethodsNonLive<R, ExcludeTestServices>) => void): void
  (name: string, f: (it: Vitest.MethodsNonLive<R, ExcludeTestServices>) => void): void
}

Source

Since 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

declare const live: Vitest.Tester<never>

Source

Since v1.0.0

makeMethods

Signature

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

Source

Since v1.0.0

prop

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 : Schema.Schema.Type<Arbs[K]> },
    ctx: V.TestContext
  ) => void,
  timeout?:
    | number
    | (V.TestOptions & {
        fastCheck?: FC.Parameters<{
          [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
        }>
      })
) => void

Source

Since v1.0.0

scoped

Signature

declare const scoped: Vitest.Tester<TestServices.TestServices | Scope.Scope>

Source

Since v1.0.0

scopedLive

Signature

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

Source

Since v1.0.0