You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactor MCP tests to use MSW instead of vi.fn() mocks #170
The MCP integration tests in src/toolsets/tests/stackone.mcp-fetch.spec.ts currently use vi.fn() to mock the RpcClient.actions.rpcAction method directly. This approach should be refactored to use MSW (Mock Service Worker) for consistency with other tests in the codebase.
Type assertion (as unknown as RpcClient) - This bypasses TypeScript's type checking
Inconsistent with other tests - Other tests use MSW handlers for HTTP mocking
Response structure mismatch - The mock returns { actionsRpcResponse: { data: null } } which doesn't match the actual server response structure { data: null, next?: string }
Test is excluded from vitest - The file is in exclude array in vitest.config.ts, so MSW setup doesn't apply
Proposed Changes
Remove the test file from vitest's exclude array
Replace vi.fn() mocks with MSW handlers in mocks/handlers.ts
Update mock responses to match the correct RpcActionResponse type:
Remove the as unknown as RpcClient type assertions
Related Context
This issue was identified during the RPC client type improvements in #152, where the response type was corrected to match the server's ActionsRpcResponseApiModel.
Acceptance Criteria
MCP tests use MSW for HTTP mocking
No vi.fn() mocks for RpcClient methods
No type assertions for RpcClient
Mock responses match actual server response structure
Activity
feat(mocks): add Hono-based MCP mock server for testing
feat(mocks): integrate MCP mock server into MSW handlers
refactor(test): replace Bun.serve with MSW + Hono for MCP tests
test(vitest): enable MCP fetch tests
chore(deps): remove unused @hono/node-server