Skip to content

Add unit tests for the Claude, Gemini and MiniMax director adapters #6

Open

Description

@blixvip

Every image adapter has a scripted-fake test in test/providers.test.mjs. Director adapters are only tested once, indirectly: direct() with DeepSeek, through the shared OpenAI-compatible compat() adapter. These parts have no coverage:

  • Claude (anthropic.chat): the x-api-key and anthropic-version headers, the top-level system field, and joining the text blocks of content
  • Gemini (gemini.chat): the x-goog-api-key header, systemInstruction, responseMimeType: 'application/json', and reading candidates[0].content.parts
  • MiniMax: compat() deliberately leaves out response_format for id === 'minimax'. Nothing checks that it stays out.
  • Base-URL overrides such as DASHSCOPE_COMPAT_URL and MOONSHOT_BASE_URL, read through baseEnv
  • empty replies, which should throw ProviderError … empty reply

Task: add test/llm.test.mjs that calls each adapter's chat() with a fake fetch, using the fake() pattern from test/providers.test.mjs. Assert on the request (URL, headers, body) and on the parsed text. No network or real keys.

Where: server/providers/llm/index.mjs:7-18 (compat), server/providers/llm/index.mjs:20-34 (anthropic), server/providers/llm/index.mjs:36-53 (gemini), server/providers/llm/index.mjs:63 (minimax entry); pattern to copy at test/providers.test.mjs:15-31.

Done when: node --test test/llm.test.mjs passes with no network and no keys set, asserting the request URL, headers and body plus the parsed text for Claude and Gemini, that the MiniMax request body has no response_format, that setting DASHSCOPE_COMPAT_URL or MOONSHOT_BASE_URL changes the request URL, and that an empty reply throws ProviderError with "empty reply"; npm test stays green.


Getting started: Node 22, no npm install needed: git clone, then npm test and npm run check. Comment here to claim it. Questions → Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions