Awesome Reviewers

When writing tests, choose the boundary intentionally: validate user-/system-relevant behavior without brittle low-level mocking, and stub only external dependencies.

Practical rules:

Example pattern (adapter wiring):

it("wires request through the real adapter", async () => {
  const fetchStub = vi.fn(() => Promise.resolve(new Response(JSON.stringify({ text: "hi" }))));
  vi.stubGlobal("fetch", fetchStub);

  const result = await transcribeAudio({
    // real adapter used
    config: { type: "openai-native", model: "gpt-4o-mini-transcribe" },
    audio: /* ... */,
  });

  expect(fetchStub).toHaveBeenCalledWith(
    expect.stringContaining("/v1/audio/transcriptions"),
    expect.any(Object)
  );
  expect(result.text).toBe("hi");
});