This implements the missing done callback feature in Bun's node:test
implementation. When a test or hook function has a length >= 2 (for tests)
or >= 1 (for hooks), it is treated as using the legacy Node.js error-first
callback pattern.
Key changes:
- Added createDeferredCallback() utility to manage callback state
- Updated createTest() to check fn.length and pass done callback when >= 2
- Updated createHook() to check fn.length and pass done callback when >= 1
- Added error detection for mixed callback+Promise usage
- Added multiple invocation protection for done callback
- Updated TypeScript types to support both callback and Promise signatures
- Fixed missing kDefaultFilePath constant
Tests:
- Added 06-done-callback.js with passing tests for done callback usage
- Added 07-done-callback-errors.js to verify error conditions
- All existing node:test tests continue to pass
Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>