What is the problem this feature would solve?
This is the same as #6096, but for V4. Credit to @dmeehan1968 and @coyaSONG
Paste the original FR here:
Description
@effect/vitest currently re-exports Vitest's beforeAll and beforeEach hooks unchanged. Vitest does not recognize a returned Effect as asynchronous work, so the Effect remains lazy and the hook body is skipped.
This change explicitly wraps both hooks. When a callback returns an Effect, it is executed and awaited through the package's existing Effect runner; synchronous and Promise-returning callbacks are passed through unchanged. Regression tests cover both suite-level and per-test Effect hooks, including the repository's concurrent test configuration.
I think effect/vitest should just wrap all the hooks. Including
{before,after,around}{Each,All}
What is the feature you are proposing to solve the problem?
A solution, similar to #6450, but the effect should also have access to the outer layer injected by it.layer.
What alternatives have you considered?
Wrap the effect in Effect.runPromise myself in vanilla vitest beforeEach. However, they don't have access to the layer.
What is the problem this feature would solve?
This is the same as #6096, but for V4. Credit to @dmeehan1968 and @coyaSONG
Paste the original FR here:
Description
@effect/vitestcurrently re-exports Vitest'sbeforeAllandbeforeEachhooks unchanged. Vitest does not recognize a returnedEffectas asynchronous work, so the Effect remains lazy and the hook body is skipped.This change explicitly wraps both hooks. When a callback returns an Effect, it is executed and awaited through the package's existing Effect runner; synchronous and Promise-returning callbacks are passed through unchanged. Regression tests cover both suite-level and per-test Effect hooks, including the repository's concurrent test configuration.
I think effect/vitest should just wrap all the hooks. Including
{before,after,around}{Each,All}What is the feature you are proposing to solve the problem?
A solution, similar to #6450, but the effect should also have access to the outer layer injected by
it.layer.What alternatives have you considered?
Wrap the effect in
Effect.runPromisemyself in vanilla vitestbeforeEach. However, they don't have access to the layer.