Skip to content

@effect/vitest: Incompatibility with vitest 4.0 - onTestFinished API change #5976

@schickling

Description

@schickling

Description

@effect/vitest version 0.27.0 is incompatible with vitest 4.0 due to breaking changes in vitest's test context API.

Environment

  • @effect/vitest: 0.27.0
  • vitest: 4.0.16 (incompatible) / 3.2.4 (compatible)
  • effect: 3.19.14

Problem

When using vitest 4.0.16, all tests fail with the error:

TypeError: ctx?.onTestFinished is not a function

The error originates from @effect/vitest/dist/esm/internal/internal.js:24:

const runPromise = ctx => effect => Effect.gen(function* () {
  const exitFiber = yield* Effect.fork(Effect.exit(effect));
  ctx?.onTestFinished(() => Fiber.interrupt(exitFiber).pipe(Effect.asVoid, Effect.runPromise));
  // ...
})

Root Cause

Vitest 4.0 introduced breaking changes to the test context API. The onTestFinished method is no longer available in the test context passed to test functions, or its signature has changed.

Workaround

Downgrade to vitest 3.2.4:

{
  "devDependencies": {
    "vitest": "3.2.4"
  }
}

Expected Behavior

@effect/vitest should support vitest 4.x, or clearly document that only vitest ^3.2.0 is supported and update peer dependencies accordingly.

Request

Please update @effect/vitest to support vitest 4.0's new test context API, or provide guidance on the migration path.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions