Skip to content

Preserve chained vitest helpers like it.describe.each through the it proxy - #6444

Merged
mikearnaldi merged 1 commit into
Effect-TS:mainfrom
rvaccone:fix/vitest-proxy-chained-helpers
Jul 18, 2026
Merged

Preserve chained vitest helpers like it.describe.each through the it proxy#6444
mikearnaldi merged 1 commit into
Effect-TS:mainfrom
rvaccone:fix/vitest-proxy-chained-helpers

Conversation

@rvaccone

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Closes #6348.

makeItProxy in packages/vitest/src/internal/internal.ts returned value.bind(target) for every function property accessed through the it proxy. Function.prototype.bind produces a fresh function without the original's own properties, and that is exactly where vitest attaches its static helpers (each, skip, only, etc.). As a result, chained access like it.describe.each(...) or it.skip.each(...) threw TypeError: it.describe.each is not a function.

This returns the property as is instead of a bound copy. Removing the bind is safe: vitest's chain functions ignore dynamic this and invoke the underlying collector with a context captured in a closure, while the helpers that do read this (each, for, skipIf, runIf) still resolve correctly because the proxy forwards every lookup it does not override, including vitest's internal context symbol, to the target. Before the proxy was introduced, makeMethods used Object.assign(it, overrides) on the vitest it directly, so chained helpers worked natively; this restores those semantics. As a side effect, property access no longer allocates a bound function each time.

Adds regression tests for it.describe.each (the reproduction from the issue, with a nested it.effect) and it.skip.each, both verified to fail against the previous implementation.

This supersedes Effect-TS/effect-smol#2302 by @truffle-dev, which proposed this same fix, and Effect-TS/effect-smol#2344 by @SAY-5, both closed in the V4 repository migration. Happy to close this in favor of either author if they would prefer to resubmit their own port.

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 88439e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@effect/vitest Patch
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rvaccone
rvaccone marked this pull request as ready for review July 17, 2026 01:29
@IMax153 IMax153 added the 4.0 label Jul 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.58 KB 6.58 KB 0.00 KB (0.00%)
batching.ts 9.19 KB 9.19 KB 0.00 KB (0.00%)
brand.ts 6.14 KB 6.14 KB 0.00 KB (0.00%)
cache.ts 9.83 KB 9.83 KB 0.00 KB (0.00%)
config.ts 18.80 KB 18.80 KB 0.00 KB (0.00%)
differ.ts 17.02 KB 17.02 KB 0.00 KB (0.00%)
http-client.ts 20.50 KB 20.50 KB 0.00 KB (0.00%)
logger.ts 10.17 KB 10.17 KB 0.00 KB (0.00%)
metric.ts 8.44 KB 8.44 KB 0.00 KB (0.00%)
optic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
pubsub.ts 14.01 KB 14.01 KB 0.00 KB (0.00%)
queue.ts 11.01 KB 11.01 KB 0.00 KB (0.00%)
schedule.ts 10.21 KB 10.21 KB 0.00 KB (0.00%)
schema-class.ts 17.86 KB 17.86 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 4.06 KB 4.06 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.25 KB 27.25 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.52 KB 12.52 KB 0.00 KB (0.00%)
schema-string.ts 10.19 KB 10.19 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.19 KB 14.19 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.65 KB 20.65 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 21.23 KB 21.23 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 17.84 KB 17.84 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 17.72 KB 17.72 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.57 KB 17.57 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 20.13 KB 20.13 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 18.09 KB 18.09 KB 0.00 KB (0.00%)
schema.ts 17.14 KB 17.14 KB 0.00 KB (0.00%)
stm.ts 11.95 KB 11.95 KB 0.00 KB (0.00%)
stream.ts 9.20 KB 9.20 KB 0.00 KB (0.00%)

@mikearnaldi
mikearnaldi merged commit eb3ea7a into Effect-TS:main Jul 18, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@effect/vitest: it.describe.each is not a function

3 participants