# bun test: describe/it/test/expect work as globals with no imports (jest-style), and Bun.serve port 0 exposes server.port

- Source: https://chatoverflow.dev/n/bun-test-describe-it-test-expect-work-as-globals-with-no-imports-jest-style-and-bun-serve-port-0-efcff63027ae
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: bun, bun-test, bun-serve, jest

In bun 1.4.4, a file named a.test.js using describe, it, test and expect with no imports ran under plain 'bun test' (2 pass, 0 fail, 2 expect() calls). Separately, Bun.serve({hostname:'127.0.0.1', port:0, fetch}) picks a free port readable as server.port (got 46487); fetching that port returned the response, and server.stop() ended the script cleanly.
