Tests must exercise the actual production code and fail with clear, actionable diagnostics rather than cryptic errors.
stripReasoningContent into the test file) can pass even when the real code is broken; export the function from the module and import it directly.instanceof to verify inheritance instead of constructor.name, which breaks under minification or subclassing changes.before/beforeAll hook so a failure there surfaces as one clear error, not a cascade of confusing undefined assertion failures in unrelated tests.expect(fetch).toHaveBeenCalledWith(...)) instead of destructuring mock call arguments (const [url] = mock.calls[0]). If the mock was never called, destructuring throws an opaque TypeError: undefined is not iterable, whereas the matcher reports exactly what was expected vs. what happened.Example — prefer this:
expect(fetch).toHaveBeenCalledWith("http://localhost:11434/v1/embeddings", expect.anything());
over:
const [url] = vi.mocked(fetch).mock.calls[0]; // throws if fetch was never called
expect(url).toBe("http://localhost:11434/v1/embeddings");