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

latest releases: @effect/typeclass@0.29.14, @effect/vitest@0.13.14, @effect/sql-sqlite-wasm@0.20.5...
3 months ago

Patch Changes

  • #3416 8cc1517 Thanks @sukovanej! - Interrupt an effect when a test finishes. This ensures allocated resources
    will be correctly released even if the test times out.

    import { it } from "@effect/vitest";
    import { Console, Effect, Layer } from "effect";
    
    class Database extends Effect.Tag("Database")<Database, {}>() {
      static readonly test = Layer.scoped(
        Database,
        Effect.acquireRelease(
          Effect.as(Console.log("database setup"), Database.of({})),
          () => Console.log("database teardown"),
        ),
      );
    }
    
    it.live(
      "testing with closable resources",
      () =>
        Effect.gen(function* () {
          const database = yield* Database;
          // performing some time consuming operations
          yield* Effect.sleep("500 millis");
        }).pipe(Effect.provide(Database.test)),
      { timeout: 100 },
    );

Don't miss a new effect release

NewReleases is sending notifications on new releases.