Skip to main content
This guide walks you through writing your first end-to-end tests for FrontMCP tools. You’ll learn how to set up the testing framework, write tests for tools, resources, and prompts, and run your test suite.
Prerequisites:

What You’ll Build

A complete E2E test suite that:
  • Starts your MCP server automatically
  • Tests tool execution with various inputs
  • Validates error handling
  • Tests resources and prompts

Step 1: Install the Testing Library


Step 2: Configure Testing

The frontmcp test command auto-generates the correct Jest/SWC config. No manual jest.e2e.config.ts needed. Add a script to your package.json:
package.json

Step 3: Write Your First Test

Create a test file in the e2e/ directory using the .e2e.spec.ts extension (not .e2e.ts). The frontmcp test command discovers tests matching e2e/**/*.e2e.spec.ts:
e2e/server.e2e.spec.ts
Run your test:
The testing library automatically:
  1. Starts your FrontMCP server
  2. Connects an MCP client
  3. Runs your test
  4. Cleans up after completion

Step 4: Test Tool Execution

Testing Successful Execution

Testing Multiple Scenarios

Testing Error Cases


Step 5: Test Tool Discovery

Verify your tools are properly registered:

Step 6: Test Resources

If your app has resources:

Step 7: Test Prompts

If your app has prompts:

Step 8: Organize Your Tests

Recommended file structure:
Use test.describe() to group related tests:
e2e/calculator.e2e.spec.ts

Complete Example

Here’s a complete test file:
e2e/server.e2e.spec.ts

Best Practices

Always test:
  • Happy path (valid inputs)
  • Edge cases (zero, negative, empty)
  • Error cases (invalid inputs, missing params)
Auto-select ports to avoid conflicts:

Next Steps

Test Fixtures

Learn about all available test fixtures

Custom Matchers

Full reference for MCP-specific matchers

Auth Testing

Test authentication and authorization

HTTP Mocking

Mock external API calls