github Effect-TS/effect @effect/vitest@0.10.5

latest releases: @effect/sql-sqlite-wasm@0.21.1, @effect/sql-sqlite-bun@0.21.8, @effect/sql-libsql@0.9.8...
one month ago

Patch Changes

  • #3689 4d91f41 Thanks @tim-smart! - add layer api to @effect/vitest

    This allows you to share a Layer between multiple tests, optionally wrapping
    the tests in a describe block.

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

Don't miss a new effect release

NewReleases is sending notifications on new releases.