libs/skills/catalog/frontmcp-testing/SKILL.md
Use when you want to write tests, run tests, add e2e tests, improve test coverage, test a tool, test a resource, or learn how to test any FrontMCP component. The skill for ALL testing needs.
npx skillsauth add agentfront/frontmcp frontmcp-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Entry point for testing FrontMCP applications. This skill helps you navigate testing strategies across component types and find the right patterns for unit, integration, and E2E tests.
setup-testing)frontmcp-development)frontmcp-deployment)Decision: Use this skill for testing strategy and routing. Open the
setup-testingreference underreferences/for hands-on Jest configuration and test writing.
frontmcp-development).setup-testing before opening any other testing skill.This is a router skill. Follow this order to pick a testing approach, then move to the target reference under references/.
references/test-tool-unit.md, references/test-e2e-handler.md, references/test-auth.md) and follow its Steps section.references/setup-testing.md).| Scenario | Reference / Section | Description |
| --------------------------------------- | ------------------------------- | ---------------------------------------------------------------------------------------------------- |
| Set up Jest, coverage, and test harness | setup-testing | Full Jest config, test utilities, and coverage thresholds |
| Write unit tests for a tool | test-tool-unit | Mock DI, validate input/output, test error paths |
| Write unit tests for a resource | setup-testing (Unit Testing) | Test URI resolution, template params, read results |
| Write unit tests for a prompt | setup-testing (Unit Testing) | Test argument handling, message generation |
| Write E2E protocol-level tests | setup-testing (E2E Testing) | Real MCP client/server, full protocol flow |
| Test authenticated endpoints | test-auth | E2E with OAuth tokens, session validation, role-based access |
| Test deployment builds | setup-testing + deploy-to-* | Smoke tests against built output |
| Test browser builds | test-browser-build | Smoke-test a frontmcp build --target browser bundle (import the bundle, optional Playwright suite) |
| Test CLI binary builds | test-cli-binary | Spawn-and-curl smoke tests for frontmcp build --target cli artifacts |
| Test with the direct API client | test-direct-client | In-memory testing via create(), connectOpenAI(), connectClaude() (no HTTP) |
| Write E2E test handler patterns | test-e2e-handler | Manual McpTestClient + TestServer E2E patterns (alternative to fixture API) |
| Unit test individual tools | test-tool-unit | Unit testing individual ToolContext subclasses with a mock context |
| Component | Unit Test Focus | E2E Test Focus | Key Assertions |
| --------- | -------------------------------------------------------- | ---------------------------------- | ----------------------------------------------------------------------- |
| Tool | Input validation, execute logic, error paths, DI mocking | tools/call via MCP client | Output matches schema, errors return MCP codes |
| Resource | URI resolution, read content, template param handling | resources/read via MCP client | Content type correct, URI patterns resolve |
| Prompt | Argument validation, message generation, multi-turn | prompts/get via MCP client | Messages match expected structure |
| Agent | LLM config, tool selection, handoff logic | Agent loop via MCP client | Tools called in order, result synthesized |
| Provider | Lifecycle hooks, factory output, singleton behavior | Indirectly via tool/resource tests | Instance reuse, cleanup on scope disposal |
| Job | Progress tracking, retry logic, attempt counting | Job execution via test harness | Progress events emitted, retries respected |
| Workflow | Step dependencies, conditions, input mapping functions | Workflow run via test harness | Steps execute in order, conditions evaluated, continueOnError respected |
| Skill | Instruction loading (inline/file/url), tool validation | Skill discovery via MCP/HTTP | Instructions resolve, tool refs validated per toolValidation mode |
| Plugin | Context extensions, provider registration, hook firing | Indirectly via tool tests | Extensions available on this, hooks fire at correct stages |
| Pattern | Rule |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| File naming | Always .spec.ts (not .test.ts); E2E uses .e2e.spec.ts |
| File organization | Split E2E tests by app/feature: e2e/calc.e2e.spec.ts, e2e/ecommerce.e2e.spec.ts. Never put all tests in a single server.e2e.spec.ts |
| Test runner | Standalone projects: use frontmcp test (auto-generates Jest/SWC config; discovers src/**/*.spec.ts(x), __tests__/**/*.spec.ts(x), and e2e/**/*.e2e.spec.ts(x); transforms both .ts and .tsx with the automatic JSX runtime; delegates to a user-provided jest.config.{ts,js,mjs,cjs,json} if present). Nx monorepos: use nx test <lib> (resolves the project's jest.config.ts). Never invoke jest --config ... directly |
| Coverage threshold | 95%+ across statements, branches, functions, lines |
| Test descriptions | Plain English, no prefixes like "PT-001"; describe behavior not implementation |
| Mocking | Mock providers via DI token replacement, never mock the framework |
| httpMock scope | httpMock intercepts HTTP in the test process only, NOT in the MCP server subprocess. Do not use httpMock to intercept server-to-API calls — those happen in the child process. Use httpMock for verifying client-to-server request shapes or mocking external APIs called from the test itself |
| Error testing | Assert instanceof specific error class AND MCP error code |
| Async | Always await async operations; use expect(...).rejects.toThrow() for async errors |
| Pattern | Correct | Incorrect | Why |
| ------------------ | ------------------------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------- |
| Test file location | fetch-weather.tool.spec.ts next to source | __tests__/fetch-weather.test.ts | Co-location with .spec.ts extension matches FrontMCP conventions |
| DI mocking | Replace token with mock via scope.register(TOKEN, mockImpl) | jest.mock('../provider') module mock | DI mocking is cleaner, type-safe, and tests the real integration path |
| Error assertions | expect(err).toBeInstanceOf(ResourceNotFoundError) | expect(err.message).toContain('not found') | Class checks are stable; message strings are fragile |
| E2E transport | Use @frontmcp/testing MCP client with real server | HTTP requests with fetch | The test client handles protocol details (session, framing) |
| Coverage gaps | Investigate uncovered branches, add targeted tests | Add istanbul ignore comments | Coverage gaps often hide real bugs; ignoring them defeats the purpose |
@frontmcp/testing preset.spec.ts extension throughout| Problem | Cause | Solution |
| ---------------------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| Jest not finding test files | Wrong file extension (.test.ts instead of .spec.ts) | Rename to .spec.ts; check testMatch in jest.config |
| Coverage below 95% | Untested error paths or conditional branches | Run frontmcp test --coverage and inspect uncovered lines in the report |
| E2E test timeout | Server startup too slow or port conflict | Increase Jest timeout; use random port allocation |
| DI resolution fails in tests | Provider not registered in test scope | Register mock providers before creating the test context |
| Istanbul shows 0% on async methods | TypeScript source-map mismatch with Istanbul | Known issue with some TS compilation settings; verify coverage with actual test output |
Each reference has matching examples under examples/<reference>/:
setup-testing| Example | Level | Description |
| ---------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| fixture-based-e2e-test | Advanced | Write E2E tests using the fixture API from @frontmcp/testing that manages server lifecycle automatically and uses MCP-specific custom matchers. |
| jest-config-with-coverage | Basic | Set up a Jest configuration file that enforces 95%+ coverage across all metrics for a FrontMCP library. |
| unit-test-tool-resource-prompt | Intermediate | Write unit tests for the three core MCP primitives, verifying that outputs match the expected MCP response shapes. |
test-auth| Example | Level | Description |
| -------------------------------------------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------- |
| oauth-flow-test | Advanced | Use MockOAuthServer to simulate an OAuth identity provider and test the authorization code flow. |
| role-based-access-test | Intermediate | Verify that tools enforce role-based access by testing admin and user tokens against protected endpoints. |
| token-factory-test | Basic | Use TestTokenFactory to create tokens and verify authenticated and unauthenticated requests. |
test-browser-build| Example | Level | Description |
| ----------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------ |
| browser-bundle-validation | Basic | Verify that the browser build produces a valid bundle without Node.js-only module references. |
| playwright-browser-test | Advanced | Use Playwright to test a browser-based MCP client that loads and calls tools from an MCP server. |
test-cli-binary| Example | Level | Description |
| ------------------------------------------------------------------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------ |
| binary-startup-test | Basic | Verify that a compiled CLI binary starts correctly and responds to health checks. |
| js-bundle-import-test | Intermediate | Verify that the compiled JS bundle can be imported and exports the expected modules after a frontmcp build step. |
test-direct-client| Example | Level | Description |
| ----------------------------------------------------------------------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| basic-create-test | Basic | Test tools in-memory without any HTTP overhead using the create() function from @frontmcp/sdk. |
| openai-claude-format-test | Intermediate | Verify that tools are returned in the correct format for OpenAI and Claude clients using connectOpenAI and connectClaude. |
test-e2e-handler| Example | Level | Description |
| --------------------------------------------------------------------------------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------- |
| basic-e2e-test | Basic | Set up a basic E2E test that starts a server, connects a client, and verifies tools are listed. |
| manual-client-with-transport | Advanced | Use McpTestClient.create() with explicit transport settings for fine-grained control over E2E tests. |
| tool-call-and-error-e2e | Intermediate | Test successful tool calls and verify that invalid inputs produce proper error responses over the full MCP protocol. |
test-tool-unit| Example | Level | Description |
| ----------------------------------------------------------------------------------- | ------------ | -------------------------------------------------------------------------------------------------------- |
| basic-tool-test | Basic | Test a simple tool's execute() method with mock context and verify the output. |
| schema-validation-test | Intermediate | Validate that a tool's Zod input schema rejects invalid data before execute() is called. |
| tool-error-handling-test | Advanced | Test that a tool throws the correct MCP error classes with proper error codes and JSON-RPC error shapes. |
Skills are distributed as plain SKILL.md files plus a sibling references/
and examples/ tree, so consumers can pick whichever access mode fits:
| Mode | How it works |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Filesystem | Read libs/skills/catalog/frontmcp-testing/ directly from a clone of the catalog repo, or from a published @frontmcp/skills install. SKILL.md is the entry point. |
| frontmcp CLI | frontmcp skills list, frontmcp skills read frontmcp-testing, frontmcp skills read frontmcp-testing:references/<file>.md, frontmcp skills install frontmcp-testing — no server required. |
| MCP skill:// | When a developer mounts this skill into their own FrontMCP server (@FrontMcp({ skills: [...] })), the SDK exposes it via SEP-2640 resources: skill://frontmcp-testing/SKILL.md, skill://frontmcp-testing/references/{file}.md, etc. The server’s skill://index.json returns the SEP-2640 discovery document for everything mounted on it. |
The catalog itself is not an MCP server. The skill:// URIs only resolve
when a server has been configured to host this skill.
setup-testing, create-tool, create-resource, create-prompt, configure-authtools
ALWAYS use this skill when the user asks to build, modify, or audit a FrontMCP tool. Covers everything inside `@Tool({...})`: class and function-style tools, Zod input/output schemas with derived `execute()` types, dependency injection (`this.get` / `this.tryGet`), error handling (`this.fail`, MCP error classes), throttling (rate-limit / concurrency / timeout), auth providers (single / multi / vault), availability constraints (`availableWhen`), elicitation (`this.elicit`), interactive UI widgets via `@Tool({ ui })` (MCP Apps / SEP-1865 — including `.tsx` FileSource, CSP, `window.FrontMcpBridge`, host-detect `resourceMode`), annotations (`readOnlyHint` / `destructiveHint` / …), `examples` metadata, registration in `@App({ tools })`, and per-tool unit testing. Does NOT cover: - Read-only data exposed via a URI — use `create-resource` - Conversation templates / system prompts — use `create-prompt` - Multi-tool orchestration loops — use `create-agent` - Background work / pipelines — use `create-job` / `create-workflow` - Server-level config (transport, sessions, auth modes) — use `config` / `auth` Triggers: `@Tool`, ToolContext, tool decorator, MCP tool, snake_case tool name, inputSchema, outputSchema, ToolInputOf, ToolOutputOf, `@Tool({ ui })`, tool UI widget, MCP Apps widget, FileSource widget, `.tsx` widget, ui.csp, ui.resourceMode, window.FrontMcpBridge, tool annotations, readOnlyHint, destructiveHint, rate-limit tool, throttle tool, concurrency tool, tool timeout, this.fail, this.respond, this.fetch, this.notify, this.progress, this.elicit, ElicitationDisabledError, ToolContext.execute, this.get(TOKEN), this.tryGet, register tool in @App, tool examples metadata, availableWhen, missingAxes, `tool()` function builder, Tool.esm, Tool.remote, PublicMcpError, ResourceNotFoundError, MCP_ERROR_CODES, ui://widget.
tools
Use when you want to add tracing, structured logging, or monitoring to your FrontMCP server. Covers OpenTelemetry instrumentation, vendor integrations (Coralogix, Datadog, Logz.io, Grafana), this.telemetry API for custom spans, structured JSON logging with sinks, and testing observability. Triggers: observability, telemetry, tracing, logging, monitoring, opentelemetry, otel, spans, datadog, coralogix, logz, grafana, winston, pino.
development
Use when implementing authorization, access control, RBAC, ABAC, or ReBAC for tools, resources, prompts, or skills. Covers JWT claims mapping, authority profiles, and policy enforcement.
tools
Domain router for project setup, scaffolding, and organization. Use this skill whenever someone asks to create a new FrontMCP project, set up an Nx monorepo, configure Redis or SQLite storage, organize project structure, compose multiple apps into one server, or manage the skills system. Also triggers for questions like 'how do I start', 'project layout', 'folder structure', 'add redis', 'set up database', or 'create a new app'.