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 Jest

Create a Jest configuration file for E2E tests:
jest.e2e.config.ts
Add a script to your package.json:
package.json

Step 3: Write Your First Test

Create a test file next to your server entry point:
src/main.e2e.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:
calculator.e2e.ts

Complete Example

Here’s a complete test file:
src/main.e2e.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