Skip to content

catpaw and kiro tests leave their globalThis.fetch in place for later files in the root bun test #877

Open

Description

@yetone

bun test at the repo root runs every file in one process, and two packages' tests replace globalThis.fetch without putting it back, so later files call through their wrappers.

  • packages/catpaw/index.test.mjs:37 sets globalThis.fetch = (input, init) => realFetch(patched, init) in beforeAll and never restores it (the afterAll at :45 stops the fake server only). patched is a URL string, so a Request's method and headers are dropped: a fetch(new Request(url, {method: "POST"}), {body}) made by a later file goes out as a GET with a body and throws fetch() request with GET/HEAD method cannot have body.
  • packages/kiro/usage.test.mjs:20 and builderid.test.mjs:22 set globalThis.fetch = offline at module load, so a file that runs after them in the same process gets the offline stub.

Seen on mote (macOS, Bun 1.4.2) while reviewing #847: bun test packages/catpaw packages/inkstone/api.test.mjs fails inkstone's "the fetch wiring is the request path" at #847's head, and bun test packages/kiro packages/inkstone/api.test.mjs fails the same test on main f379bf9 (14 fails, 1.3ms). Each passes alone.

Fix: save and restore globalThis.fetch in afterAll in both packages, and have catpaw's wrapper keep a Request's method, headers and body when it rewrites the URL.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions