Skip to content

Commit

Permalink
fix effect vitest layer (#4382)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinassefranche authored Feb 1, 2025
1 parent fd92e69 commit e374d94
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-ghosts-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/vitest": patch
---

Fix @effect.vitest layer method not running tests in some cases
4 changes: 2 additions & 2 deletions packages/vitest/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export const layer = <R, E>(layer_: Layer.Layer<R, E>, options?: {
return args[0](makeIt(V.it))
}

return V.describe(args[0], (it) => {
return V.describe(args[0], () => {
V.beforeAll(
() => runPromise()(Effect.asVoid(runtimeEffect)),
options?.timeout ? Duration.toMillis(options.timeout) : undefined
Expand All @@ -236,7 +236,7 @@ export const layer = <R, E>(layer_: Layer.Layer<R, E>, options?: {
() => runPromise()(Scope.close(scope, Exit.void)),
options?.timeout ? Duration.toMillis(options.timeout) : undefined
)
return args[1](makeIt(it))
return args[1](makeIt(V.it))
})
}

Expand Down
15 changes: 15 additions & 0 deletions packages/vitest/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ describe("layer", () => {
yield* Fiber.join(fiber)
}))
})

layer(Foo.Live)("with a name", (it) => {
describe("with a nested describe", () => {
it.effect("adds context", () =>
Effect.gen(function*() {
const foo = yield* Foo
expect(foo).toEqual("foo")
}))
})
it.effect("adds context", () =>
Effect.gen(function*() {
const foo = yield* Foo
expect(foo).toEqual("foo")
}))
})
})

// property testing
Expand Down

0 comments on commit e374d94

Please sign in to comment.