fix: resolve type errors from vitest 4 Mock type changes

vi.fn() now returns Mock<Procedure | Constructable> in vitest 4, which
isn't directly callable or assignable to typed function signatures. Fix
by narrowing the mock type where it's called directly, and casting at
the assignment site for global.fetch.
This commit is contained in:
Alaister Young committed 2026-04-14 11:50:40 +09:00
1 parent 1d4520a832
commit 3362015076
2 files changed
+2 -2

No files matched your search

@@ -108,7 +108,7 @@ vi.mock(import('@/lib/breadcrumbs'), async (importOriginal) => {
let createSupportStorageClientMock: ReturnType<typeof vi.fn>
let getBreadcrumbSnapshotMock: ReturnType<typeof vi.fn>
let generateAttachmentUrlSpy: ReturnType<typeof vi.fn>
let generateAttachmentUrlSpy: ReturnType<typeof vi.fn<(...args: any[]) => any>>
// Mock sonner toast
vi.mock('sonner', () => ({
@@ -14,7 +14,7 @@ describe('ai/tools/incident-tools', () => {
beforeEach(() => {
vi.clearAllMocks()
mockFetch = vi.fn()
global.fetch = mockFetch
global.fetch = mockFetch as typeof fetch
// Mock AbortSignal.timeout
mockAbortSignal = new AbortController().signal