mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
## Summary Implements `onTestFinished()` for `bun:test`, which runs after all `afterEach` hooks have completed. ## Implementation - Added `onTestFinished` export to the test module in `jest.zig` - Modified `genericHook` in `bun_test.zig` to handle `onTestFinished` as a special case that: - Can only be called inside a test (not in describe blocks or preload) - Appends hooks at the very end of the execution sequence - Added comprehensive tests covering basic ordering, multiple callbacks, async callbacks, and interaction with other hooks ## Execution Order When called inside a test: 1. Test body executes 2. `afterAll` hooks (if added inside the test) 3. `afterEach` hooks 4. `onTestFinished` hooks ✨ ## Test Plan - ✅ All new tests pass with `bun bd test` - ✅ Tests correctly fail with `USE_SYSTEM_BUN=1` (feature not in released version) - ✅ Verifies correct ordering with `afterEach`, `afterAll`, and multiple `onTestFinished` calls - ✅ Tests async `onTestFinished` callbacks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: pfg <pfg@pfg.pw>
TypeScript types for Bun
These are the type definitions for Bun's JavaScript runtime APIs.
Installation
Install the @types/bun npm package:
# yarn/npm/pnpm work too
# @types/bun is an ordinary npm package
bun add -D @types/bun
That's it! VS Code and TypeScript automatically load @types/* packages into your project, so the Bun global and all bun:* modules should be available immediately.
Contributing
The @types/bun package is a shim that loads bun-types. The bun-types package lives in the Bun repo under packages/bun-types.
To add a new file, add it under packages/bun-types. Then add a triple-slash directive pointing to it inside ./index.d.ts.
+ /// <reference path="./newfile.d.ts" />
bun build
