Skip to main content
Glama
validator.test.ts939 B
import { describe, it, expect, vi } from "vitest"; import { validateCodeHandler } from "./validator.js"; import fs from "fs/promises"; import { exec } from "child_process"; vi.mock("fs/promises"); vi.mock("child_process"); vi.mock("util", () => ({ promisify: (fn: any) => async (cmd: string) => { if (cmd.includes("prettier")) return { stdout: "", stderr: "" }; // Success if (cmd.includes("python")) return { stdout: "", stderr: "" }; throw new Error("Command failed"); }, })); describe("Validator Tools", () => { describe("validateCodeHandler", () => { it("should validate js code", async () => { (fs.writeFile as any).mockResolvedValue(undefined); (fs.unlink as any).mockResolvedValue(undefined); const result = await validateCodeHandler({ code: "const x=1;", language: "javascript", }); expect(result.content[0].text).toContain("Code is valid"); }); }); });

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/millsydotdev/Code-MCP'

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