Skip to content

fix(vitest): preserve subproperties on chained access through it proxy - #2302

Closed
truffle-dev wants to merge 1 commit into
Effect-TS:mainfrom
truffle-dev:fix/it-proxy-preserve-subproperties
Closed

truffle-dev wants to merge 1 commit into
Effect-TS:mainfrom
truffle-dev:fix/it-proxy-preserve-subproperties

Conversation

@truffle-dev

Copy link
Copy Markdown
Contributor

Type

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

Description

Closes Effect-TS/effect#6348.

makeItProxy in packages/vitest/src/internal/internal.ts returned value.bind(target) whenever a non-override property access produced a function. Binding strips the function's own properties, so chained access like it.describe.each(...), it.skip.each(...), or it.only.each(...) resolved the chained step to undefined and threw TypeError: it.describe.each is not a function.

Reflect.get(target, property, receiver) already returns the underlying vitest functions correctly; vitest's chainable APIs do not depend on this === V.it. Removing the bind restores chained access without changing direct-call behavior.

Adds a regression case in packages/vitest/test/index.test.ts covering it.describe.each, it.skip.each, and it.only.each. With the bind removed the suite reports 26 passed | 1 expected fail | 6 skipped; reverting only the source change (test in place) reproduces the reporter's error against it.skip.each.

The `makeItProxy` get trap bound returned functions to the target with
`value.bind(target)`, which strips each function's own properties. Chained
access like `it.describe.each`, `it.skip.each`, or `it.only.each` therefore
resolved to `undefined` and threw `TypeError: ... is not a function`.

Drop the bind and return the value as-is. Adds a regression case covering
`it.describe.each`, `it.skip.each`, and `it.only.each`.

Closes #2301
@changeset-bot

changeset-bot Bot commented May 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 87c0704

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

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.72 KB 6.72 KB 0.00 KB (0.00%)
batching.ts 9.23 KB 9.23 KB 0.00 KB (0.00%)
brand.ts 6.20 KB 6.20 KB 0.00 KB (0.00%)
cache.ts 9.70 KB 9.70 KB 0.00 KB (0.00%)
config.ts 18.40 KB 18.40 KB 0.00 KB (0.00%)
differ.ts 16.85 KB 16.86 KB -0.01 KB (-0.07%)
http-client.ts 20.20 KB 20.20 KB 0.00 KB (0.00%)
logger.ts 10.18 KB 10.18 KB 0.00 KB (0.00%)
metric.ts 8.56 KB 8.56 KB 0.00 KB (0.00%)
optic.ts 7.37 KB 7.37 KB 0.00 KB (0.00%)
pubsub.ts 13.80 KB 13.80 KB 0.00 KB (0.00%)
queue.ts 11.08 KB 11.08 KB 0.00 KB (0.00%)
schedule.ts 10.08 KB 10.08 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.24 KB 26.31 KB -0.07 KB (-0.26%)
schema-string-transformation.ts 12.59 KB 12.59 KB 0.00 KB (0.00%)
schema-string.ts 10.34 KB 10.34 KB 0.00 KB (0.00%)
schema-template-literal.ts 13.94 KB 13.94 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 18.51 KB 18.51 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 21.13 KB 21.13 KB -0.01 KB (-0.02%)
schema-toCodecJson.ts 17.67 KB 17.68 KB -0.01 KB (-0.06%)
schema-toEquivalence.ts 17.61 KB 17.61 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.44 KB 17.44 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 19.96 KB 19.97 KB -0.01 KB (-0.03%)
schema-toRepresentation.ts 18.00 KB 18.00 KB 0.00 KB (0.00%)
schema.ts 17.05 KB 17.05 KB 0.00 KB (0.00%)
stm.ts 11.95 KB 11.95 KB 0.00 KB (0.00%)
stream.ts 9.25 KB 9.25 KB 0.00 KB (0.00%)

@truffle-dev

Copy link
Copy Markdown
Contributor Author

Hi @gcanti, polite nudge in case this slipped past triage. The fix is one line in packages/vitest/src/internal/internal.ts — swap value.bind(target) for Reflect.get(target, property, receiver) so chained access like it.describe.each / it.skip.each / it.only.each survives the proxy. Happy to rebase if anything has moved.

@thife455

Copy link
Copy Markdown

Bump, this is very useful when nesting layers

@truffle-dev

Copy link
Copy Markdown
Contributor Author

Second user hitting this now (thanks @thife455). Still a one-line change in packages/vitest/src/internal/internal.ts: Reflect.get(target, property, receiver) instead of value.bind(target), so chained access through the it proxy (it.describe.each, it.skip.each, it.only.each) keeps its subproperties. Rebased and green. @tim-smart @gcanti happy to adjust if the proxy has moved since.

@IMax153

IMax153 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Hi @truffle-dev,

The Effect V4 codebase has been merged back into Effect-TS/effect, where V4 development now continues on the main branch.

The GitHub issues linked to this PR have also been migrated to the effect repository:

Please use these migrated issue links in the replacement PR.

GitHub cannot transfer pull requests between repositories. If you would like to continue this contribution, please open a replacement pull request against Effect-TS/effect:main and include a link to this PR for its existing discussion and review history.

After opening the replacement, please reply here with its URL so maintainers can verify the migration and close this source PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants