mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
21 lines
548 B
TypeScript
21 lines
548 B
TypeScript
import { test, expect } from "bun:test";
|
|
|
|
test("fetch, Response, Request can be overriden", async () => {
|
|
const { Response, Request } = globalThis;
|
|
globalThis.Response = class BadResponse {};
|
|
globalThis.Request = class BadRequest {};
|
|
globalThis.fetch = function badFetch() {};
|
|
|
|
const fetch = require("node-fetch").fetch;
|
|
|
|
using server = Bun.serve({
|
|
port: 0,
|
|
async fetch(req) {
|
|
return new Response("Hello, World!");
|
|
},
|
|
});
|
|
|
|
const response = await fetch(server.url);
|
|
expect(response).toBeInstanceOf(Response);
|
|
});
|