fix(bun:test): return an object when a mock function is constructed with new#31386
Open
robobun wants to merge 10 commits into
Open
fix(bun:test): return an object when a mock function is constructed with new#31386robobun wants to merge 10 commits into
robobun wants to merge 10 commits into
Claude / Claude Code Review
completed
May 31, 2026 in 11m 54s
Code review found 1 potential issue
Found 1 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:1015-1017 |
Mock functions lack a default .prototype, so instanceof throws on constructed instances |
Annotations
Check notice on line 1017 in src/jsc/bindings/JSMockFunction.cpp
claude / Claude Code Review
Mock functions lack a default .prototype, so instanceof throws on constructed instances
Pre-existing nit, not a regression: `JSMockFunction` never installs a `.prototype` own-property (InternalFunction doesn't auto-create one, unlike JSFunction), so `jest.fn().prototype` is `undefined`. With construct now actually working, the default case `const fn = jest.fn(); (new fn()) instanceof fn` throws `TypeError: instanceof called on an object with an invalid prototype property`, and `Object.getPrototypeOf(new fn())` is `Object.prototype` rather than `fn.prototype` — both diverge from Jes
Loading