Skip to content

fix(bun:test): constructing a mock function must return an object#31381

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

fix(bun:test): constructing a mock function must return an object#31381
robobun wants to merge 1 commit into
mainfrom
farm/4e0236f3/fix-mock-construct

fix(bun:test): return an object when constructing a mock function

6fbf94d
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed May 25, 2026 in 10m 54s

Code review found 1 potential issue

Found 4 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:1003-1015 mock.instances not populated on construct

Annotations

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

See this annotation in the file changed.

@claude claude / Claude Code Review

mock.instances not populated on construct

Not blocking, and pre-existing, but worth a follow-up: `mock.instances` is still never populated — `fn->instances` is only declared, cleared, lazily created empty, and GC-visited, never written to — so even with the new construct path, `new fn(); fn.mock.instances` is `[]` where Jest gives `[<instance>]`. Since this PR now creates the very `thisObject` that `mock.instances` is meant to record, it'd be a natural place to push it (and, to fully match Jest, push `thisValue` on every call alongside