test: make unsafe test coercion explicit

Move test coercion out of a hidden global and require each test to import the helper so review tools and runtime scripts can see the unsafe boundary.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-12 15:38:31 +09:00
parent ce5da13fc5
commit d5fbada13d
103 changed files with 700 additions and 554 deletions
@@ -1,4 +1,5 @@
import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test"
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
describe("tool-input-cache", () => {
const originalSetInterval = globalThis.setInterval
@@ -33,11 +34,11 @@ describe("tool-input-cache", () => {
test("#given cleanup timer started #when stop cleanup runs #then interval is cleared and cache is emptied", async () => {
//#given
const intervalHandle = testCoerce<ReturnType<typeof setInterval>>({ unref: mock(() => {}) })
const intervalHandle = unsafeTestValue<ReturnType<typeof setInterval>>({ unref: mock(() => {}) })
const setIntervalMock = mock(() => intervalHandle)
const clearIntervalMock = mock(() => {})
globalThis.setInterval = testCoerce<typeof setInterval>(setIntervalMock)
globalThis.clearInterval = testCoerce<typeof clearInterval>(clearIntervalMock)
globalThis.setInterval = unsafeTestValue<typeof setInterval>(setIntervalMock)
globalThis.clearInterval = unsafeTestValue<typeof clearInterval>(clearIntervalMock)
const modulePath = new URL("./tool-input-cache.ts", import.meta.url).pathname
const cacheModule = await import(`${modulePath}?stop-clear`)