mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
## Summary Fixes #23133 This PR fixes a bug where lifecycle hooks (`beforeAll`, `beforeEach`, `afterAll`, `afterEach`) would throw an error when called with a function and options object: ```typescript beforeAll(() => { console.log("beforeAll") }, { timeout: 10_000 }) ``` Previously, this would throw: `error: beforeAll() expects a function as the second argument` ## Root Cause The issue was in `ScopeFunctions.parseArguments()` at `src/bun.js/test/ScopeFunctions.zig:342`. When parsing two arguments, it always treated them as `(description, callback)` instead of checking if they could be `(callback, options)`. ## Solution Updated the two-argument parsing logic to check if the first argument is a function and the second is not a function. In that case, treat them as `(callback, options)` instead of `(description, callback)`. ## Changes - Modified `src/bun.js/test/ScopeFunctions.zig` to handle `(callback, options)` case - Added regression test at `test/regression/issue/23133.test.ts` ## Testing ✅ Verified the fix works with the reproduction case from the issue ✅ Added comprehensive regression test covering all lifecycle hooks with both object and numeric timeout options ✅ All existing jest-hooks tests still pass ✅ Test fails with `USE_SYSTEM_BUN=1` and passes with the fixed build 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: pfg <pfg@pfg.pw>
1.3 KiB
1.3 KiB