opendesign tests: the real fetch is put back after each test, so every package's tests after it pass again (publish red since #84)

bun test runs every package's files in one process. opendesign's tests
set globalThis.fetch directly, and mock.restore() doesn't undo that, so
every file after it (minimax, trae, zcode, zen-free: 148 tests) got
opendesign's stub and failed. The publish run at 3db704a went red at its
test job, so neither dist nor npm ran. #84's review saw these failures
and wrongly put them down to load.

Run: `bun test packages/opendesign packages/minimax packages/zen-free
packages/trae/usage.test.mjs` with HOME in a temp dir: 234 pass, 0 fail.
Without this change: 34 fail.
This commit is contained in:
yetone
2026-10-15 06:57:55 +08:00
parent 3db704a677
commit 8a28086bf1
+4
View File
@@ -4,8 +4,12 @@ import {
OpenDesignAuthPlugin,
} from "./index.mjs"
// bun test runs every package's files in one process: a fetch left
// stubbed here answers every test file after this one
const realFetch = globalThis.fetch
afterEach(() => {
mock.restore()
globalThis.fetch = realFetch
})
// ---- the sign-in it keeps ----------------------------------------------------