Open jackens opened 3 weeks ago
Describe the bug
GlobalRegistrator.register() processes the Response class, causing Bun.serve to not work in bun:test mode
GlobalRegistrator.register()
Response
Bun.serve
bun:test
To Reproduce
bug.test.ts:
bug.test.ts
import { file, serve } from 'bun' import { execSync } from 'child_process' import { join } from 'path' const server = serve({ port: 12345, fetch ({ url }) { return new Response(file(join('.', new URL(url).pathname))) } }) execSync('open http://127.0.0.1:12345/index.html') await new Promise(resolve => setTimeout(resolve, 3_000)) server.stop()
index.html:
index.html
<!doctype html> <html lang="en"> <head><meta charset="UTF-8" /></head> <body>The content of the ‘index.html’ file is irrelevant…</body> </html>
bunfig.toml:
bunfig.toml
[test] preload = "./test/happy-dom.ts"
./test/happy-dom.ts:
./test/happy-dom.ts
import { GlobalRegistrator } from '@happy-dom/global-registrator' GlobalRegistrator.register()
The execution of bun bug.test.ts works OK, but executing bun test bug.test.ts causes an error (see attached screenshot).
bun bug.test.ts
bun test bug.test.ts
Expected behavior
GlobalRegistrator.register() should omit the Response class
Screenshots
Device:
Darwin 23.5.0 x86_64 i386
@happy-dom/global-registrator
14.12.3
Additional context
Cf. https://github.com/oven-sh/bun/issues/12408
Describe the bug
GlobalRegistrator.register()
processes theResponse
class, causingBun.serve
to not work inbun:test
modeTo Reproduce
bug.test.ts
:index.html
:bunfig.toml
:./test/happy-dom.ts
:The execution of
bun bug.test.ts
works OK, but executingbun test bug.test.ts
causes an error (see attached screenshot).Expected behavior
GlobalRegistrator.register()
should omit theResponse
classScreenshots
Device:
Darwin 23.5.0 x86_64 i386
@happy-dom/global-registrator
:14.12.3
Additional context
Cf. https://github.com/oven-sh/bun/issues/12408