Skip to content

Latest commit

 

History

History

README.md

@frontmcp/testing

E2E testing framework for FrontMCP servers.

NPM

Install

npm install -D @frontmcp/testing

Peer dependencies: @frontmcp/sdk, jest, @jest/globals. Optional: @playwright/test (for browser OAuth flow testing).

Quick Start

import { test, expect } from '@frontmcp/testing';
import MyServer from './src/main';

test.use({ server: MyServer });

test('server exposes tools', async ({ mcp }) => {
  const tools = await mcp.tools.list();
  expect(tools).toContainTool('my-tool');
});

test('tool execution works', async ({ mcp }) => {
  const result = await mcp.tools.call('my-tool', { input: 'test' });
  expect(result).toBeSuccessful();
});
npx frontmcp test

The library handles server startup, MCP client connection, test execution, and cleanup.

Fixtures

Fixture Description
mcp Auto-connected MCP client — tools, resources, prompts, raw protocol, notifications, logs
server Server control — createClient(), restart(), onHook(), getLogs()
auth Token factory — createToken(), createExpiredToken(), createInvalidToken(), pre-built test users

Custom Matchers

ToolstoContainTool, toBeSuccessful, toBeError, toHaveTextContent, toHaveImageContent, toHaveResourceContent

ResourcestoContainResource, toContainResourceTemplate, toHaveMimeType

PromptstoContainPrompt, toHaveMessages, toHaveRole, toContainText

ProtocoltoBeValidJsonRpc, toHaveResult, toHaveError, toHaveErrorCode

Tool UItoHaveRenderedHtml, toContainHtmlElement, toContainBoundValue, toBeXssSafe, toHaveWidgetMetadata, toHaveCssClass, toNotContainRawContent, toHaveProperHtmlStructure

Configuration

test.use({
  server: MyServer,
  port: 3003, // default: auto
  transport: 'streamable-http', // or 'sse'
  auth: { mode: 'public' },
  logLevel: 'debug',
  env: { API_KEY: 'test' },
});

Docs

Topic Link
Getting started Testing Overview
Testing tools Tools
Testing Tool UI Tool UI
Testing resources Resources
Testing prompts Prompts
Testing auth Authentication
Testing transports Transports
HTTP mocking HTTP Mocking

Related Packages

License

Apache-2.0 — see LICENSE.