fix: correct blob mock so mikeApi tests pass on Node 22 and 24
From the PR description
Summary
Fixes 4 tests in frontend/src/app/lib/mikeApi.test.ts that fail locally on Node 24 with TypeError: blob.text is not a function, while passing in CI (Node 22).
Root cause
The tests already construct real Response objects (new Response(...)), so the request/response mocking itself was not the problem. The actual cause is in the shared Vitest jsdom test environment setup:
- Vitest's built-in jsdom environment always overrides
globalThis.Blobwith jsdom's ownBlobimplementation, which has never implemented.text(),.arrayBuffer(), or.stream()- onlyslice,size, andtype. - Node's built-in
Response.prototype.blob()resolves itsBlobconstructor dynamically fromglobalThisat call time. On Node 24 this meansresponse.blob()returns a jsdom-shaped blob missing those methods; on Node 22 it apparently does not exhibit this behavior, so the same tests pass there. - Since the repo's own
package.jsonpinsengines.node: ">=22"with no upper bound, Node 24 is a legitimately supported local dev version, so this was a real (if narrow) bug, not just an unsupported-toolchain situation.
Fix
Restore the real Node Blob (imported directly from node:buffer, independent of the globalThis override jsdom performs) in frontend/vitest.setup.ts, which runs before every test file. This makes response.blob() behave identically on Node 22 and Node 24, and does not touch any production code path.
Changes
frontend/vitest.setup.ts: restoreglobalThis.Blobto the nativenode:bufferBlobafter jsdom's environment setup overrides it, with a comment explaining why.
Test plan
-
cd frontend && npx vitest run src/app/lib/mikeApi.test.ts- 178/178 pass (previously 174/178, with the 4 tests named in #361 failing). -
cd frontend && npx vitest run(full frontend suite) - 98 files / 641 tests, all pass - confirming no regression from the globalBlobchange on other tests that rely onFile/Blob/FormData(upload flows, clipboard export, etc). -
cd frontend && npx tsc --noEmit- clean. -
cd frontend && npx eslint vitest.setup.ts- clean. -
npm run build --prefix frontendwas not run in this environment: this worktree'snode_modulesis a symlink to a sibling worktree (to avoid annpm installunder a non-pinned local Node version per repo policy), and Turbopack refuses to build through a symlink that points outside its detected project root. Confirmed this Turbopack error is pre-existing and unrelated to this change by reproducing it identically with the fix stashed out.tsc --noEmitcovers the type-checking this build step would otherwise gate.
Closes #361
Our analysis
Restore native Blob support in frontend tests — read the full analysis →
Think the analysis missed something the PR description covers?
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-406.md from
inside the repo you want the changes in.