fix(tests): stabilize auto-update-checker isolation under bun

This commit is contained in:
YeonGyu-Kim 2026-02-19 01:40:58 +09:00
parent 8c726f5589
commit b4183339e7
2 changed files with 7 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { describe, it, expect, mock } from "bun:test"
import { afterEach, describe, it, expect, mock } from "bun:test"
const mockShowConfigErrorsIfAny = mock(async () => {})
const mockShowModelCacheWarningIfNeeded = mock(async () => {})
@ -42,6 +42,11 @@ mock.module("../../shared/logger", () => ({
const { createAutoUpdateCheckerHook } = await import("./hook")
afterEach(() => {
delete process.env.OPENCODE_CLI_RUN_MODE
mock.restore()
})
describe("createAutoUpdateCheckerHook", () => {
it("skips startup toasts and checks in CLI run mode", async () => {
//#given - CLI run mode enabled
@ -78,6 +83,5 @@ describe("createAutoUpdateCheckerHook", () => {
expect(mockShowVersionToast).not.toHaveBeenCalled()
expect(mockRunBackgroundUpdateCheck).not.toHaveBeenCalled()
delete process.env.OPENCODE_CLI_RUN_MODE
})
})

View File

@ -40,7 +40,7 @@ mock.module("../../../shared/logger", () => ({
log: () => {},
}))
const { runBackgroundUpdateCheck } = await import("./background-update-check")
const { runBackgroundUpdateCheck } = await import("./background-update-check?test")
describe("runBackgroundUpdateCheck", () => {
const mockCtx = { directory: "/test" } as any