Skip to main content
Glama
Arize-ai

@arizeai/phoenix-mcp

Official
by Arize-ai
addSpanNote.test.ts2.07 kB
import { addSpanNote } from "../../src/spans/addSpanNote"; import { beforeEach, describe, expect, it, vi } from "vitest"; // Create mock POST function const mockPOST = vi.fn(); // Mock the fetch module vi.mock("openapi-fetch", () => ({ default: () => ({ POST: mockPOST.mockResolvedValue({ data: { data: { id: "test-note-id-1" }, }, error: null, }), use: () => {}, }), })); describe("addSpanNote", () => { beforeEach(() => { // Clear all mocks before each test vi.clearAllMocks(); // Reset default mock behavior mockPOST.mockResolvedValue({ data: { data: { id: "test-note-id-1" }, }, error: null, }); }); it("should add a span note", async () => { const result = await addSpanNote({ spanNote: { spanId: "123abc", note: "This is a test note", }, }); expect(result).toEqual({ id: "test-note-id-1" }); }); it("should trim span ID", async () => { await addSpanNote({ spanNote: { spanId: " 123abc ", note: "This is a test note", }, }); expect(mockPOST).toHaveBeenCalledWith("/v1/span_notes", { body: { data: { span_id: "123abc", note: "This is a test note", }, }, }); }); it("should throw error when API returns error", async () => { mockPOST.mockResolvedValueOnce({ data: undefined, error: "Span not found", }); await expect( addSpanNote({ spanNote: { spanId: "nonexistent", note: "This will fail", }, }) ).rejects.toThrow("Failed to add span note: Span not found"); }); it("should throw error when no data is returned", async () => { mockPOST.mockResolvedValueOnce({ data: undefined, error: undefined, }); await expect( addSpanNote({ spanNote: { spanId: "123abc", note: "This will fail", }, }) ).rejects.toThrow("Failed to add span note: no data returned"); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Arize-ai/phoenix'

If you have feedback or need assistance with the MCP directory API, please join our Discord server