Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-vitest-it-proxy-subproperties.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/vitest": patch
---

Fix `it.describe.each`, `it.skip.each`, `it.only.each` (and similar chained access on the `it` proxy) by removing an unnecessary `value.bind(target)` from `makeItProxy`'s `get` trap. The bind stripped each function's own properties (`.each`, `.skip`, `.only`, ...), so `it.describe.each` resolved to `undefined` and threw `TypeError: it.describe.each is not a function`.
3 changes: 1 addition & 2 deletions packages/vitest/src/internal/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ const makeItProxy = <Methods extends object>(
if (property in overrides) {
return Reflect.get(overrides, property)
}
const value = Reflect.get(target, property, receiver)
return typeof value === "function" ? value.bind(target) : value
return Reflect.get(target, property, receiver)
}
})

Expand Down
19 changes: 19 additions & 0 deletions packages/vitest/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ it.effect.skip(
() => Effect.die("skipped anyway")
)

// chained access through proxy preserves subproperties (regression for
// https://github.com/Effect-TS/effect-smol/issues/2301)

it.describe("it.describe.each", () => {
it.describe.each(["a", "b"] as const)("%s", (text) => {
it("matches the case label", () => {
assert.include(["a", "b"], text)
})
})
})

it.skip.each([1, 2])("it.skip.each is skipped (%s)", (n) => {
assert.fail(`should never run for ${n}`)
})

it.only.each([] as Array<number>)("it.only.each has no cases", () => {
assert.fail("no cases registered")
})

// skipIf

it.effect.skipIf(true)("effect skipIf (true)", () => Effect.die("skipped anyway"))
Expand Down