@frontmcp/testing exports, types, and methods.
Test Function
test
The main test function with fixture injection.test.use
Configure fixtures for a test file.| Option | Type | Default | Description |
|---|---|---|---|
server | string | — | Path to server entry file (required) |
port | number | Auto | Port to run server on |
transport | 'sse' | 'streamable-http' | 'streamable-http' | Transport protocol |
auth | AuthOptions | — | Authentication configuration |
logLevel | 'debug' | 'info' | 'warn' | 'error' | 'warn' | Server log level |
env | Record<string, string> | — | Environment variables |
startupTimeout | number | 30000 | Startup timeout in ms |
baseUrl | string | — | Connect to existing server |
McpTestClient
The primary fixture for testing MCP servers.Tools API
tools.list
List all available tools.name, description, and inputSchema.
tools.call
Call a tool with arguments.| Parameter | Type | Description |
|---|---|---|
name | string | Tool name |
args | Record<string, unknown> | Tool arguments |
ToolResult with methods:
Resources API
resources.list
List static resources.uri, name, description, and mimeType.
resources.listTemplates
List resource templates.uriTemplate, name, and description.
resources.read
Read a resource by URI.ResourceContent with methods:
Prompts API
prompts.list
List available prompts.name, description, and arguments.
prompts.get
Get a prompt with arguments.PromptResult with:
Session & Connection
isConnected
Check connection status.sessionId
Get the current session ID.serverInfo
Get server information.protocolVersion
Get the MCP protocol version.capabilities
Get server capabilities.hasCapability
Check for a specific capability.authenticate
Authenticate the client with a JWT token.disconnect
Disconnect from the server.Raw Protocol API
raw.request
Send a raw JSON-RPC request.raw.notify
Send a JSON-RPC notification (no response expected).raw.sendRaw
Send raw string data (for testing parse errors).Logging & Tracing
logs.all
Get all captured logs.logs.filter
Filter logs by level.logs.search
Search logs by text.logs.clear
Clear captured logs.trace.all
Get all request traces.trace.last
Get the last request trace.trace.clear
Clear request traces.Auth Fixture
Theauth fixture generates JWT tokens for authentication testing.
createToken
Create a valid JWT token.createExpiredToken
Create an expired token for testing expiration handling.createInvalidToken
Create a token with an invalid signature.users
Pre-built test user configurations.getJwks
Get the public JWKS for token verification.getIssuer
Get the token issuer.getAudience
Get the token audience.Server Fixture
Theserver fixture provides server control.
info
Server information.createClient
Create an additional MCP client.restart
Restart the server.getLogs
Get server-side logs.clearLogs
Clear server logs.Mock Registry
Themcp.mock API for mocking MCP responses.
mock.add
Add a mock definition.mock.tool
Convenience method for mocking tool responses.mock.toolError
Mock a tool error.mock.resource
Mock a resource response.mock.clear
Clear all mocks.Request Interceptors
Themcp.intercept API for intercepting requests and responses.
intercept.request
Intercept outgoing requests.intercept.response
Intercept incoming responses.intercept.delay
Add delay to all requests.intercept.failMethod
Fail requests to a specific method.HTTP Mock API
ThehttpMock module for mocking external HTTP requests.
httpMock.interceptor
Create an HTTP interceptor.Interceptor Methods
get, post, put, delete
Create method-specific mocks.any
Match any HTTP method.mock
Full mock definition.allowPassthrough
Allow unmatched requests to reach the network.assertDone
Assert all one-time mocks were used.pending
Get unused mocks.restore
Restore original fetch function.MockHandle
Returned by mock methods.Response Helpers
httpResponse
Pre-built HTTP response creators.mockResponse
Pre-built MCP response creators.Custom Matchers
All custom Jest matchers added by@frontmcp/testing.
Tool Matchers
Result Matchers
Content Matchers
Resource Matchers
Prompt Matchers
JSON-RPC Matchers
Error Codes
Common MCP error codes for use in tests.| Code | Name | Description |
|---|---|---|
-32700 | Parse error | Invalid JSON |
-32600 | Invalid request | Invalid JSON-RPC structure |
-32601 | Method not found | Unknown method |
-32602 | Invalid params | Invalid parameters |
-32603 | Internal error | Server error |
-32001 | Unauthorized | Authentication required |
-32002 | Resource not found | Resource doesn’t exist |
-32800 | Request cancelled | Request was cancelled |

