Skip to content

bun:test: return an object when constructing a mock function - #31373

Closed
robobun wants to merge 1 commit into
mainfrom
farm/4e0236f3/mock-construct-return-object
Closed

bun:test: return an object when constructing a mock function#31373
robobun wants to merge 1 commit into
mainfrom
farm/4e0236f3/mock-construct-return-object

bun:test: return an object when constructing a mock function

a170803
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed May 25, 2026 in 9m 48s

Code review found 1 potential issue

Found 2 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 0
🟣 Pre-existing 1
Severity File:Line Issue
🟣 Pre-existing src/jsc/bindings/JSMockFunction.cpp:1004-1013 mock.instances not populated on construct (pre-existing)

Annotations

Check notice on line 1013 in src/jsc/bindings/JSMockFunction.cpp

See this annotation in the file changed.

@claude claude / Claude Code Review

mock.instances not populated on construct (pre-existing)

Pre-existing, not introduced here: `mock.instances` is exposed on the mock object but is never populated — `jsMockFunctionCallImpl` pushes to `calls`/`contexts`/`invocationCallOrder`/`returnValues` but never to `fn->instances`. Now that mocks have a real `[[Construct]]` path, users will reach for `fn.mock.instances[0]` (the canonical Jest API for constructor calls) and find it empty. Might be worth pushing `thisValue` into `instances` alongside `contexts` while you're in here, but it shouldn't b