fix: resolve TypeScript type errors in test files
- Add vitest/globals to tsconfig.json types array to provide type definitions for global test functions (describe, it, expect, vi) - Fix vi.fn type parameter in useDirectorySettings.test.tsx from <[], Promise<string>> to <() => Promise<string>> - Remove unused setMcpConfig import from MSW handlers - Add type assertions for mock.calls access in McpFormModal tests to resolve union type inference issues This ensures pnpm typecheck passes without errors while maintaining test functionality with vitest globals: true configuration.
This commit is contained in:
@@ -203,7 +203,7 @@ const renderForm = (props?: Partial<React.ComponentProps<typeof McpFormModal>>)
|
||||
fireEvent.click(screen.getByText("common.add"));
|
||||
|
||||
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
||||
const [id, payload, options] = onSave.mock.calls[0];
|
||||
const [id, payload, options] = (onSave as any).mock.calls[0];
|
||||
expect(id).toBe("my-server");
|
||||
expect(payload).toMatchObject({
|
||||
id: "my-server",
|
||||
@@ -281,7 +281,7 @@ command = "run"
|
||||
fireEvent.click(screen.getByText("common.add"));
|
||||
|
||||
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
||||
const [id, payload] = onSave.mock.calls[0];
|
||||
const [id, payload] = (onSave as any).mock.calls[0];
|
||||
expect(id).toBe("demo");
|
||||
expect(payload.server).toEqual({ type: "stdio", command: "run" });
|
||||
expect(toastErrorMock).not.toHaveBeenCalled();
|
||||
@@ -342,7 +342,7 @@ type = "stdio"
|
||||
fireEvent.click(screen.getByText("common.save"));
|
||||
|
||||
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
||||
const [id, entry, options] = onSave.mock.calls[0];
|
||||
const [id, entry, options] = (onSave as any).mock.calls[0];
|
||||
expect(id).toBe("existing");
|
||||
expect(entry.server.command).toBe("updated");
|
||||
expect(entry.enabled).toBe(true);
|
||||
|
||||
@@ -7,7 +7,7 @@ const getAppConfigDirOverrideMock = vi.hoisted(() => vi.fn());
|
||||
const getConfigDirMock = vi.hoisted(() => vi.fn());
|
||||
const selectConfigDirectoryMock = vi.hoisted(() => vi.fn());
|
||||
const setAppConfigDirOverrideMock = vi.hoisted(() => vi.fn());
|
||||
const homeDirMock = vi.hoisted(() => vi.fn<[], Promise<string>>());
|
||||
const homeDirMock = vi.hoisted(() => vi.fn<() => Promise<string>>());
|
||||
const joinMock = vi.hoisted(() => vi.fn(async (...segments: string[]) => segments.join("/")));
|
||||
const toastErrorMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
getAppConfigDirOverride,
|
||||
setAppConfigDirOverrideState,
|
||||
getMcpConfig,
|
||||
setMcpConfig,
|
||||
setMcpServerEnabled,
|
||||
upsertMcpServer,
|
||||
deleteMcpServer,
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
},
|
||||
"types": ["vitest/globals"]
|
||||
},
|
||||
"include": ["src/**/*", "tests/**/*"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
|
||||
Reference in New Issue
Block a user