Skip to main content
Glama

MongoDB MCP Server

Official
by mongodb-js
operationWithFallback.test.ts977 B
import { describe, it, expect, vi } from "vitest"; import { operationWithFallback } from "../../../src/helpers/operationWithFallback.js"; describe("operationWithFallback", () => { it("returns operation result when operation succeeds", async () => { const successfulOperation = vi.fn().mockResolvedValue("success"); const fallbackValue = "fallback"; const result = await operationWithFallback(successfulOperation, fallbackValue); expect(result).toBe("success"); expect(successfulOperation).toHaveBeenCalledOnce(); }); it("returns fallback value when operation throws an error", async () => { const failingOperation = vi.fn().mockRejectedValue(new Error("Operation failed")); const fallbackValue = "fallback"; const result = await operationWithFallback(failingOperation, fallbackValue); expect(result).toBe("fallback"); expect(failingOperation).toHaveBeenCalledOnce(); }); });

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/mongodb-js/mongodb-mcp-server'

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