@frontmcp/testing uses a fixture-based testing approach inspired by Playwright. Fixtures are pre-configured objects automatically injected into your test functions, eliminating boilerplate setup code.
Available Fixtures
Configuring Fixtures
Usetest.use() to configure fixtures. Called at the top of a file it applies to the whole file; called inside a test.describe() it applies to that block only.
Configuration Options
Servers that serve MCP somewhere other than /
A server configured with http: { entryPath: '/mcp' } serves MCP at /mcp, and the test client follows it:
{"error":"Not Found","entryPaths":["/mcp"]} — the client reconnects there on its own. If it still cannot connect, the error names the paths the server reported instead of a bare HTTP 404.
entryPath applies to the MCP endpoint only. OAuth and discovery endpoints stay at the server root, which is where the server mounts them.
Scoping test.use() to a describe
test.use() is scoped to the describe block it is called in. Options from nested blocks are merged over the outer ones (env is merged key by key), and every distinct configuration gets its own server, which the block that configured it also stops. A block without its own test.use() shares its parent’s server.
auth: { mode, type } is passed to the server process as FRONTMCP_TEST_AUTH_MODE and FRONTMCP_TEST_AUTH_TYPE, which the server entry file can read. auth.mode: 'public' also keeps the mcp client anonymous.
Parameterised tests
test.each and test.describe.each pass the row values to the callback. For test.each the fixtures come first, then the row values:
Conditional skipping
test.skip(condition, reason) skips every test registered after it in the enclosing block — the Playwright idiom, and the natural way to gate a suite on credentials:
test.describe inherits an outer skip. The (name, fn) form still skips a single named test.
MCP Client Fixture
Themcp fixture is your primary interface for testing MCP servers.
Tools API
Resources API
Prompts API
Session & Server Info
Raw Protocol Access
Logging & Debugging
Auth Fixture
Theauth fixture creates JWT tokens for testing authentication flows.
Creating Tokens
Pre-built Test Users
Testing Edge Cases
JWKS Access
Server Fixture
Theserver fixture provides server control and multi-client support.
Server Information
Creating Additional Clients
Server Logs
Restart Server
Fixture Lifecycle
Understanding when fixtures are created and destroyed:The server is shared across all tests in a file for performance. Starting a server is expensive (100-500ms), so sharing it dramatically improves test speed.
Best Practices
Do:- Use
test.use()once at the top of each test file - Clear logs and traces between tests if needed
- Disconnect additional clients created via
server.createClient() - Use
port: 0for automatic port selection in CI. Ports are reserved with a lock that also covers other Jest workers, so parallel files do not collide
- Modify shared server state without cleanup
- Create many clients without disconnecting them
- Rely on test execution order
- Use hardcoded ports in parallel test runs