@frontmcp/skills 0.0.1 → 1.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +2 -2
  2. package/catalog/TEMPLATE.md +58 -13
  3. package/catalog/frontmcp-config/SKILL.md +156 -0
  4. package/catalog/{auth/configure-auth/references/auth-modes.md → frontmcp-config/references/configure-auth-modes.md} +5 -0
  5. package/catalog/frontmcp-config/references/configure-auth.md +243 -0
  6. package/catalog/frontmcp-config/references/configure-elicitation.md +183 -0
  7. package/catalog/frontmcp-config/references/configure-http.md +210 -0
  8. package/catalog/frontmcp-config/references/configure-session.md +210 -0
  9. package/catalog/{config/configure-throttle/references/guard-config.md → frontmcp-config/references/configure-throttle-guard-config.md} +5 -0
  10. package/catalog/frontmcp-config/references/configure-throttle.md +234 -0
  11. package/catalog/{config/configure-transport/references/protocol-presets.md → frontmcp-config/references/configure-transport-protocol-presets.md} +5 -0
  12. package/catalog/frontmcp-config/references/configure-transport.md +200 -0
  13. package/catalog/frontmcp-config/references/setup-redis.md +9 -0
  14. package/catalog/frontmcp-config/references/setup-sqlite.md +9 -0
  15. package/catalog/frontmcp-deployment/SKILL.md +152 -0
  16. package/catalog/frontmcp-deployment/references/build-for-browser.md +143 -0
  17. package/catalog/frontmcp-deployment/references/build-for-cli.md +191 -0
  18. package/catalog/{deployment/build-for-sdk/SKILL.md → frontmcp-deployment/references/build-for-sdk.md} +66 -20
  19. package/catalog/frontmcp-deployment/references/deploy-to-cloudflare.md +218 -0
  20. package/catalog/{deployment/deploy-to-lambda/SKILL.md → frontmcp-deployment/references/deploy-to-lambda.md} +77 -59
  21. package/catalog/{deployment/deploy-to-node/references/Dockerfile.example → frontmcp-deployment/references/deploy-to-node-dockerfile.md} +18 -4
  22. package/catalog/{deployment/deploy-to-node/SKILL.md → frontmcp-deployment/references/deploy-to-node.md} +69 -36
  23. package/catalog/frontmcp-deployment/references/deploy-to-vercel-config.md +65 -0
  24. package/catalog/frontmcp-deployment/references/deploy-to-vercel.md +229 -0
  25. package/catalog/frontmcp-development/SKILL.md +126 -0
  26. package/catalog/frontmcp-development/references/create-adapter.md +170 -0
  27. package/catalog/{development/create-agent/references/llm-config.md → frontmcp-development/references/create-agent-llm-config.md} +10 -5
  28. package/catalog/{development/create-agent/SKILL.md → frontmcp-development/references/create-agent.md} +83 -40
  29. package/catalog/{development/create-job/SKILL.md → frontmcp-development/references/create-job.md} +62 -15
  30. package/catalog/{plugins/create-plugin-hooks/SKILL.md → frontmcp-development/references/create-plugin-hooks.md} +100 -7
  31. package/catalog/frontmcp-development/references/create-plugin.md +506 -0
  32. package/catalog/{development/create-prompt/SKILL.md → frontmcp-development/references/create-prompt.md} +65 -22
  33. package/catalog/{development/create-provider/SKILL.md → frontmcp-development/references/create-provider.md} +63 -23
  34. package/catalog/{development/create-resource/SKILL.md → frontmcp-development/references/create-resource.md} +148 -26
  35. package/catalog/{development/create-skill-with-tools/SKILL.md → frontmcp-development/references/create-skill-with-tools.md} +174 -20
  36. package/catalog/{development/create-skill/SKILL.md → frontmcp-development/references/create-skill.md} +114 -28
  37. package/catalog/{development/create-tool/references/tool-annotations.md → frontmcp-development/references/create-tool-annotations.md} +5 -0
  38. package/catalog/{development/create-tool/references/output-schema-types.md → frontmcp-development/references/create-tool-output-schema-types.md} +5 -0
  39. package/catalog/{development/create-tool/SKILL.md → frontmcp-development/references/create-tool.md} +172 -23
  40. package/catalog/{development/create-workflow/SKILL.md → frontmcp-development/references/create-workflow.md} +61 -14
  41. package/catalog/frontmcp-development/references/decorators-guide.md +754 -0
  42. package/catalog/frontmcp-development/references/official-adapters.md +199 -0
  43. package/catalog/{plugins/official-plugins/SKILL.md → frontmcp-development/references/official-plugins.md} +97 -27
  44. package/catalog/frontmcp-extensibility/SKILL.md +103 -0
  45. package/catalog/frontmcp-extensibility/references/vectoriadb.md +289 -0
  46. package/catalog/frontmcp-guides/SKILL.md +420 -0
  47. package/catalog/frontmcp-guides/references/example-knowledge-base.md +641 -0
  48. package/catalog/frontmcp-guides/references/example-task-manager.md +517 -0
  49. package/catalog/frontmcp-guides/references/example-weather-api.md +297 -0
  50. package/catalog/frontmcp-production-readiness/SKILL.md +98 -0
  51. package/catalog/frontmcp-production-readiness/references/common-checklist.md +156 -0
  52. package/catalog/frontmcp-production-readiness/references/production-browser.md +46 -0
  53. package/catalog/frontmcp-production-readiness/references/production-cli-binary.md +62 -0
  54. package/catalog/frontmcp-production-readiness/references/production-cli-daemon.md +61 -0
  55. package/catalog/frontmcp-production-readiness/references/production-cloudflare.md +52 -0
  56. package/catalog/frontmcp-production-readiness/references/production-lambda.md +53 -0
  57. package/catalog/frontmcp-production-readiness/references/production-node-sdk.md +66 -0
  58. package/catalog/frontmcp-production-readiness/references/production-node-server.md +61 -0
  59. package/catalog/frontmcp-production-readiness/references/production-vercel.md +52 -0
  60. package/catalog/frontmcp-setup/SKILL.md +132 -0
  61. package/catalog/frontmcp-setup/references/frontmcp-skills-usage.md +280 -0
  62. package/catalog/{setup/multi-app-composition/SKILL.md → frontmcp-setup/references/multi-app-composition.md} +66 -19
  63. package/catalog/{setup/nx-workflow/SKILL.md → frontmcp-setup/references/nx-workflow.md} +79 -17
  64. package/catalog/frontmcp-setup/references/project-structure-nx.md +251 -0
  65. package/catalog/frontmcp-setup/references/project-structure-standalone.md +217 -0
  66. package/catalog/frontmcp-setup/references/readme-guide.md +226 -0
  67. package/catalog/{setup/setup-project/SKILL.md → frontmcp-setup/references/setup-project.md} +63 -58
  68. package/catalog/{setup/setup-redis/SKILL.md → frontmcp-setup/references/setup-redis.md} +60 -82
  69. package/catalog/{setup/setup-sqlite/SKILL.md → frontmcp-setup/references/setup-sqlite.md} +65 -72
  70. package/catalog/frontmcp-testing/SKILL.md +135 -0
  71. package/catalog/{testing/setup-testing/SKILL.md → frontmcp-testing/references/setup-testing.md} +79 -63
  72. package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-auth.md +5 -0
  73. package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-browser-build.md +5 -0
  74. package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-cli-binary.md +5 -0
  75. package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-direct-client.md +5 -0
  76. package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-e2e-handler.md +5 -0
  77. package/catalog/{testing/setup-testing → frontmcp-testing}/references/test-tool-unit.md +6 -0
  78. package/catalog/skills-manifest.json +337 -382
  79. package/package.json +2 -2
  80. package/src/index.d.ts +1 -1
  81. package/src/index.js.map +1 -1
  82. package/src/loader.js +0 -1
  83. package/src/loader.js.map +1 -1
  84. package/src/manifest.d.ts +15 -3
  85. package/src/manifest.js +3 -3
  86. package/src/manifest.js.map +1 -1
  87. package/catalog/adapters/create-adapter/SKILL.md +0 -127
  88. package/catalog/adapters/official-adapters/SKILL.md +0 -136
  89. package/catalog/auth/configure-auth/SKILL.md +0 -250
  90. package/catalog/auth/configure-session/SKILL.md +0 -201
  91. package/catalog/config/configure-elicitation/SKILL.md +0 -136
  92. package/catalog/config/configure-http/SKILL.md +0 -167
  93. package/catalog/config/configure-throttle/SKILL.md +0 -189
  94. package/catalog/config/configure-transport/SKILL.md +0 -151
  95. package/catalog/deployment/build-for-browser/SKILL.md +0 -95
  96. package/catalog/deployment/build-for-cli/SKILL.md +0 -100
  97. package/catalog/deployment/deploy-to-cloudflare/SKILL.md +0 -192
  98. package/catalog/deployment/deploy-to-vercel/SKILL.md +0 -196
  99. package/catalog/deployment/deploy-to-vercel/references/vercel.json.example +0 -60
  100. package/catalog/development/decorators-guide/SKILL.md +0 -598
  101. package/catalog/plugins/create-plugin/SKILL.md +0 -336
  102. package/catalog/setup/frontmcp-skills-usage/SKILL.md +0 -200
  103. package/catalog/setup/project-structure-nx/SKILL.md +0 -186
  104. package/catalog/setup/project-structure-standalone/SKILL.md +0 -153
@@ -0,0 +1,135 @@
1
+ ---
2
+ name: frontmcp-testing
3
+ description: '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.'
4
+ tags: [router, testing, jest, e2e, coverage, quality, guide]
5
+ category: testing
6
+ targets: [all]
7
+ bundle: [recommended, full]
8
+ priority: 10
9
+ visibility: both
10
+ license: Apache-2.0
11
+ metadata:
12
+ docs: https://docs.agentfront.dev/frontmcp/testing/overview
13
+ ---
14
+
15
+ # FrontMCP Testing Router
16
+
17
+ 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.
18
+
19
+ ## When to Use This Skill
20
+
21
+ ### Must Use
22
+
23
+ - Setting up testing infrastructure for a new FrontMCP project
24
+ - Deciding how to test a specific component type (tool, resource, prompt, agent)
25
+ - Planning a testing strategy that covers unit, E2E, and coverage requirements
26
+
27
+ ### Recommended
28
+
29
+ - Looking up testing patterns for a component type you haven't tested before
30
+ - Understanding the relationship between unit tests, E2E tests, and coverage thresholds
31
+ - Troubleshooting test failures or coverage gaps
32
+
33
+ ### Skip When
34
+
35
+ - You need detailed Jest configuration and test harness setup (go directly to `setup-testing`)
36
+ - You need to build components, not test them (see `frontmcp-development`)
37
+ - You need to deploy, not test (see `frontmcp-deployment`)
38
+
39
+ > **Decision:** Use this skill for testing strategy and routing. Use `setup-testing` for hands-on Jest configuration and test writing.
40
+
41
+ ## Scenario Routing Table
42
+
43
+ | Scenario | Skill / Section | Description |
44
+ | --------------------------------------- | ------------------------------- | ------------------------------------------------------------ |
45
+ | Set up Jest, coverage, and test harness | `setup-testing` | Full Jest config, test utilities, and coverage thresholds |
46
+ | Write unit tests for a tool | `setup-testing` (Unit Testing) | Mock DI, validate input/output, test error paths |
47
+ | Write unit tests for a resource | `setup-testing` (Unit Testing) | Test URI resolution, template params, read results |
48
+ | Write unit tests for a prompt | `setup-testing` (Unit Testing) | Test argument handling, message generation |
49
+ | Write E2E protocol-level tests | `setup-testing` (E2E Testing) | Real MCP client/server, full protocol flow |
50
+ | Test authenticated endpoints | `test-auth` | E2E with OAuth tokens, session validation, role-based access |
51
+ | Test deployment builds | `setup-testing` + `deploy-to-*` | Smoke tests against built output |
52
+ | Test browser builds | `test-browser-build` | Testing browser builds |
53
+ | Test CLI binary builds | `test-cli-binary` | Testing CLI binary builds |
54
+ | Test with the direct API client | `test-direct-client` | Testing with the direct API client |
55
+ | Write E2E test handler patterns | `test-e2e-handler` | E2E test handler patterns |
56
+ | Unit test individual tools | `test-tool-unit` | Unit testing individual tools |
57
+
58
+ ## Testing Strategy by Component Type
59
+
60
+ | Component | Unit Test Focus | E2E Test Focus | Key Assertions |
61
+ | --------- | -------------------------------------------------------- | ---------------------------------- | ----------------------------------------------------------------------- |
62
+ | Tool | Input validation, execute logic, error paths, DI mocking | `tools/call` via MCP client | Output matches schema, errors return MCP codes |
63
+ | Resource | URI resolution, read content, template param handling | `resources/read` via MCP client | Content type correct, URI patterns resolve |
64
+ | Prompt | Argument validation, message generation, multi-turn | `prompts/get` via MCP client | Messages match expected structure |
65
+ | Agent | LLM config, tool selection, handoff logic | Agent loop via MCP client | Tools called in order, result synthesized |
66
+ | Provider | Lifecycle hooks, factory output, singleton behavior | Indirectly via tool/resource tests | Instance reuse, cleanup on scope disposal |
67
+ | Job | Progress tracking, retry logic, attempt counting | Job execution via test harness | Progress events emitted, retries respected |
68
+ | Workflow | Step dependencies, conditions, input mapping functions | Workflow run via test harness | Steps execute in order, conditions evaluated, continueOnError respected |
69
+ | Skill | Instruction loading (inline/file/url), tool validation | Skill discovery via MCP/HTTP | Instructions resolve, tool refs validated per `toolValidation` mode |
70
+ | Plugin | Context extensions, provider registration, hook firing | Indirectly via tool tests | Extensions available on `this`, hooks fire at correct stages |
71
+
72
+ ## Cross-Cutting Testing Patterns
73
+
74
+ | Pattern | Rule |
75
+ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
76
+ | File naming | Always `.spec.ts` (not `.test.ts`); E2E uses `.e2e.spec.ts` |
77
+ | 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` |
78
+ | Test runner | Use `frontmcp test` (not `jest --config ...`). It auto-generates the correct Jest/SWC config |
79
+ | Coverage threshold | 95%+ across statements, branches, functions, lines |
80
+ | Test descriptions | Plain English, no prefixes like "PT-001"; describe behavior not implementation |
81
+ | Mocking | Mock providers via DI token replacement, never mock the framework |
82
+ | 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 |
83
+ | Error testing | Assert `instanceof` specific error class AND MCP error code |
84
+ | Async | Always `await` async operations; use `expect(...).rejects.toThrow()` for async errors |
85
+
86
+ ## Common Patterns
87
+
88
+ | Pattern | Correct | Incorrect | Why |
89
+ | ------------------ | ------------------------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------- |
90
+ | 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 |
91
+ | 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 |
92
+ | Error assertions | `expect(err).toBeInstanceOf(ResourceNotFoundError)` | `expect(err.message).toContain('not found')` | Class checks are stable; message strings are fragile |
93
+ | E2E transport | Use `@frontmcp/testing` MCP client with real server | HTTP requests with `fetch` | The test client handles protocol details (session, framing) |
94
+ | Coverage gaps | Investigate uncovered branches, add targeted tests | Add `istanbul ignore` comments | Coverage gaps often hide real bugs; ignoring them defeats the purpose |
95
+
96
+ ## Verification Checklist
97
+
98
+ ### Infrastructure
99
+
100
+ - [ ] Jest configured with `@frontmcp/testing` preset
101
+ - [ ] Coverage thresholds set to 95% in jest.config
102
+ - [ ] Test files use `.spec.ts` extension throughout
103
+
104
+ ### Unit Tests
105
+
106
+ - [ ] Each tool has unit tests covering happy path, validation errors, and DI failures
107
+ - [ ] Each resource has unit tests covering URI resolution and read content
108
+ - [ ] Provider lifecycle (init, dispose) tested where applicable
109
+
110
+ ### E2E Tests
111
+
112
+ - [ ] At least one E2E test exercises full MCP protocol flow (connect, list, call, disconnect)
113
+ - [ ] Authenticated E2E tests use proper test tokens (not mocked auth)
114
+ - [ ] E2E tests clean up state after execution
115
+
116
+ ### CI Integration
117
+
118
+ - [ ] Tests run in CI pipeline on every PR
119
+ - [ ] Coverage report published and enforced
120
+ - [ ] Failing tests block merge
121
+
122
+ ## Troubleshooting
123
+
124
+ | Problem | Cause | Solution |
125
+ | ---------------------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------------------- |
126
+ | Jest not finding test files | Wrong file extension (`.test.ts` instead of `.spec.ts`) | Rename to `.spec.ts`; check `testMatch` in jest.config |
127
+ | Coverage below 95% | Untested error paths or conditional branches | Run `frontmcp test --coverage` and inspect uncovered lines in the report |
128
+ | E2E test timeout | Server startup too slow or port conflict | Increase Jest timeout; use random port allocation |
129
+ | DI resolution fails in tests | Provider not registered in test scope | Register mock providers before creating the test context |
130
+ | 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 |
131
+
132
+ ## Reference
133
+
134
+ - [Testing Documentation](https://docs.agentfront.dev/frontmcp/testing/overview)
135
+ - Related skills: `setup-testing`, `create-tool`, `create-resource`, `create-prompt`, `configure-auth`
@@ -1,53 +1,34 @@
1
1
  ---
2
2
  name: setup-testing
3
- description: Configure and run unit and E2E tests for FrontMCP applications. Use when writing tests, setting up Jest, configuring coverage, or testing tools and resources.
4
- tags:
5
- - testing
6
- - jest
7
- - e2e
8
- - quality
9
- bundle:
10
- - recommended
11
- - full
12
- visibility: both
13
- priority: 5
14
- parameters:
15
- - name: test-type
16
- description: Type of test to set up (unit, e2e, or both)
17
- type: string
18
- required: false
19
- default: both
20
- - name: coverage-threshold
21
- description: Minimum coverage percentage required
22
- type: number
23
- required: false
24
- default: 95
25
- examples:
26
- - scenario: Set up unit tests for a tool with Jest
27
- parameters:
28
- test-type: unit
29
- expected-outcome: Tool execute method is tested with mocked context, assertions verify output schema
30
- - scenario: Set up E2E tests against a running MCP server
31
- parameters:
32
- test-type: e2e
33
- expected-outcome: McpTestClient connects to server, calls tools, and verifies responses with MCP matchers
34
- - scenario: Configure full test suite with 95% coverage enforcement
35
- parameters:
36
- test-type: both
37
- coverage-threshold: 95
38
- expected-outcome: Jest runs unit and E2E tests with coverage thresholds enforced in CI
39
- license: MIT
40
- compatibility: Requires Node.js 18+, Jest 29+, and @frontmcp/testing for E2E tests
41
- metadata:
42
- category: testing
43
- difficulty: beginner
44
- docs: https://docs.agentfront.dev/frontmcp/testing/overview
3
+ description: Configure Jest, write unit and E2E tests, and enforce 95%+ coverage for FrontMCP applications
45
4
  ---
46
5
 
47
6
  # Set Up Testing for FrontMCP Applications
48
7
 
49
8
  This skill covers testing FrontMCP applications at three levels: unit tests for individual tools/resources/prompts, E2E tests exercising the full MCP protocol, and manual testing with `frontmcp dev`.
50
9
 
10
+ ## When to Use This Skill
11
+
12
+ ### Must Use
13
+
14
+ - Writing the first unit test for a new tool, resource, or prompt class
15
+ - Setting up Jest configuration and coverage thresholds for a FrontMCP library
16
+ - Creating E2E tests that exercise the full MCP protocol via `McpTestClient`
17
+
18
+ ### Recommended
19
+
20
+ - Adding coverage enforcement to CI for an existing library that lacks thresholds
21
+ - Writing authenticated E2E tests with `TestTokenFactory` and `MockOAuthServer`
22
+ - Migrating existing `.test.ts` files to the required `.spec.ts` naming convention
23
+
24
+ ### Skip When
25
+
26
+ - Building a new tool class from scratch (see `create-tool`)
27
+ - Creating resources or prompts before you have anything to test (see `create-resource`, `create-prompt`)
28
+ - Debugging deployment issues unrelated to test configuration (see `deploy-to-node`, `deploy-to-vercel`)
29
+
30
+ > **Decision:** Use this skill when you need to configure, write, or run Jest tests for FrontMCP tools, resources, or prompts.
31
+
51
32
  ## Testing Standards
52
33
 
53
34
  FrontMCP requires:
@@ -65,7 +46,7 @@ FrontMCP requires:
65
46
 
66
47
  Place test files next to the source file or in a `__tests__` directory:
67
48
 
68
- ```
49
+ ```text
69
50
  src/
70
51
  tools/
71
52
  my-tool.ts
@@ -350,7 +331,7 @@ describe('Advanced E2E', () => {
350
331
  });
351
332
 
352
333
  client = await McpTestClient.create({ baseUrl: server.info.baseUrl })
353
- .withTransport('streamable-http')
334
+ .withTransport('modern') // 'modern' preset enables streamable HTTP + strict sessions
354
335
  .buildAndConnect();
355
336
  });
356
337
 
@@ -514,26 +495,61 @@ node scripts/fix-unused-imports.mjs feature/my-branch
514
495
  | Playwright browser tests | UI tests with Playwright | `.pw.spec.ts` |
515
496
  | Constructor validation | Unit test verifying throws on invalid input | `.spec.ts` |
516
497
 
517
- ## Common Mistakes
498
+ ## Common Patterns
499
+
500
+ | Pattern | Correct | Incorrect | Why |
501
+ | ---------------- | -------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------ |
502
+ | Test file naming | `my-tool.spec.ts`, `my-tool.e2e.spec.ts` | `my-tool.test.ts`, `my-tool.test.tsx` | Nx and Jest configs only recognize `.spec.ts` convention |
503
+ | Test description | `'should return formatted output for valid input'` | `'PT-001: test formatted output'` | Descriptive names; no ID prefixes |
504
+ | Mock types | `const ctx = { scope: { get: jest.fn() } } as unknown` | `const ctx: any = { scope: { get: jest.fn() } }` | Strict TypeScript; avoid `any` in mocks |
505
+ | Error assertion | `expect(err).toBeInstanceOf(ResourceNotFoundError)` | `expect(() => ...).toThrow()` | Verify the exact error class and MCP error code, not just that something threw |
506
+ | Constructor test | Always test `new MyService({})` throws on invalid config | Skip constructor validation | Catches misconfiguration early; required for 95% branch coverage |
507
+ | E2E test imports | `import { test, expect } from '@frontmcp/testing'` | `import { expect } from '@jest/globals'` | `@frontmcp/testing` provides MCP-specific matchers like `toContainTool()` |
508
+ | Coverage check | `nx test my-lib --coverage` before push | Push without coverage check | CI enforces 95% thresholds; catch failures locally first |
509
+
510
+ ## Verification Checklist
511
+
512
+ ### Configuration
513
+
514
+ - [ ] Jest config exists with `coverageThreshold` set to 95% for all metrics
515
+ - [ ] `tsconfig.spec.json` exists and extends the base tsconfig
516
+ - [ ] `@frontmcp/testing` is installed as a dev dependency for E2E tests
517
+ - [ ] Test files use `.spec.ts` (unit), `.e2e.spec.ts` (E2E), or `.perf.spec.ts` (perf) extension
518
+
519
+ ### Unit Tests
520
+
521
+ - [ ] Each tool's `execute()` method is tested with valid and invalid inputs
522
+ - [ ] Each resource's `read()` method is tested and output matches `ReadResourceResult` shape
523
+ - [ ] Each prompt's `execute()` method is tested and output matches `GetPromptResult` shape
524
+ - [ ] Constructor validation tests verify throws on invalid config
525
+ - [ ] Error classes are verified with `instanceof` checks and `mcpErrorCode` assertions
526
+
527
+ ### E2E Tests
528
+
529
+ - [ ] Fixture-based tests use `test.use({ server, port })` for server lifecycle
530
+ - [ ] Tools appear in `tools/list` response via `toContainTool()` matcher
531
+ - [ ] Tool calls return expected results via `toBeSuccessful()` matcher
532
+ - [ ] Authenticated tests use `TestTokenFactory` and verify rejection without token
533
+
534
+ ### CI Integration
535
+
536
+ - [ ] `nx test <lib> --coverage` passes locally with 95%+ on all metrics
537
+ - [ ] Unused imports are cleaned via `node scripts/fix-unused-imports.mjs`
538
+ - [ ] No TypeScript warnings in test files
539
+
540
+ ## Troubleshooting
518
541
 
519
- - **Using `.test.ts` file extension** -- all test files must use `.spec.ts`. The Nx and Jest configurations expect this convention.
520
- - **Testing implementation details** -- test inputs and outputs, not internal method calls. Tools should be tested through their `execute` interface.
521
- - **Skipping constructor validation tests** -- always test that constructors throw on invalid input.
522
- - **Skipping error `instanceof` checks** -- verify that thrown errors are instances of the correct error class, not just that an error was thrown.
523
- - **Using test ID prefixes** -- do not use prefixes like "PT-001" in test names. Use descriptive names like "should return formatted output for valid input".
524
- - **Falling below 95% coverage** -- the CI pipeline enforces coverage thresholds. Run `nx test <lib> --coverage` locally before pushing.
525
- - **Using `any` in test mocks** -- use `unknown` or properly typed mocks. Follow the strict TypeScript guidelines.
542
+ | Problem | Cause | Solution |
543
+ | -------------------------------------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
544
+ | Jest cannot find test files | Files use `.test.ts` instead of `.spec.ts` | Rename to `.spec.ts`; Nx test runner only picks up `.spec.ts` by default |
545
+ | Coverage below 95% threshold | Untested branches or constructor paths | Run `nx test <lib> --coverage` and check the HTML report for uncovered lines |
546
+ | E2E test times out on `TestServer.start()` | Server entrypoint fails to start or wrong port | Verify `server` path and `port` in `test.use()`; check server logs for startup errors |
547
+ | `toContainTool` matcher not found | Using `expect` from Jest instead of `@frontmcp/testing` | Import `expect` from `@frontmcp/testing` to get MCP-specific matchers |
548
+ | `McpTestClient.create()` connection refused | Test server not running or wrong `baseUrl` | Ensure `TestServer.start()` completes before creating client; verify port matches |
549
+ | Istanbul shows 0% coverage for async methods | TypeScript compilation source-map mismatch | Known issue with `ts-jest` and certain async patterns; check `tsconfig.spec.json` source-map settings |
550
+ | Auth E2E test returns 401 unexpectedly | Token not set or expired | Call `mcp.setAuthToken(token)` before the tool call; use `auth.createToken()` with valid claims |
526
551
 
527
552
  ## Reference
528
553
 
529
- - Testing package: [`@frontmcp/testing`](https://docs.agentfront.dev/frontmcp/testing/overview)
530
- - Test client: `McpTestClient` import from `@frontmcp/testing`
531
- - Test client builder: `McpTestClient.builder()` — fluent API for test setup
532
- - MCP matchers: `toContainTool()`, `toBeSuccessful()` — import from `@frontmcp/testing`
533
- - Test fixtures: `createTestFixture()` — import from `@frontmcp/testing`
534
- - Test server: `TestServer` — import from `@frontmcp/testing`
535
- - Performance testing: `perfTest()`, `MetricsCollector` — import from `@frontmcp/testing`
536
- - Auth testing: `TestTokenFactory`, `MockOAuthServer` — import from `@frontmcp/testing`
537
- - Interceptors: `TestInterceptor` — import from `@frontmcp/testing`
538
- - HTTP mocking: `HttpMock` — import from `@frontmcp/testing`
539
- - [Source code on GitHub](https://github.com/agentfront/frontmcp/tree/main/libs/testing)
554
+ - [Testing Documentation](https://docs.agentfront.dev/frontmcp/testing/overview)
555
+ - Related skills: `create-tool`, `create-resource`, `create-prompt`, `setup-project`, `nx-workflow`
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: test-auth
3
+ description: Test authenticated MCP servers with TestTokenFactory, MockOAuthServer, and role-based access
4
+ ---
5
+
1
6
  # Testing with Authentication
2
7
 
3
8
  ```typescript
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: test-browser-build
3
+ description: Validate browser build output for Node.js-free bundles and test with Playwright
4
+ ---
5
+
1
6
  # Testing Browser Build
2
7
 
3
8
  After building with `frontmcp build --target browser`, validate the output:
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: test-cli-binary
3
+ description: Test CLI binary and SEA build for startup, health check, and JS bundle import
4
+ ---
5
+
1
6
  # Testing CLI Binary / SEA Build
2
7
 
3
8
  After building with `frontmcp build --target cli`, test the binary:
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: test-direct-client
3
+ description: In-memory testing with create() and connectOpenAI/connectClaude without HTTP overhead
4
+ ---
5
+
1
6
  # Testing with Direct Client (No HTTP)
2
7
 
3
8
  Uses `connect()` or `create()` for in-memory testing without HTTP overhead.
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: test-e2e-handler
3
+ description: Full MCP protocol E2E tests over HTTP with McpTestClient and TestServer
4
+ ---
5
+
1
6
  # E2E Testing with McpTestClient (HTTP Handler)
2
7
 
3
8
  Tests the full MCP protocol over HTTP — validates tools, resources, prompts end-to-end.
@@ -1,6 +1,12 @@
1
+ ---
2
+ name: test-tool-unit
3
+ description: Unit test a ToolContext execute method with mock context, inputs, and Zod schema validation
4
+ ---
5
+
1
6
  # Unit Testing a Tool
2
7
 
3
8
  ```typescript
9
+ import { z } from 'zod';
4
10
  import { ToolContext } from '@frontmcp/sdk';
5
11
  import { AddTool } from '../tools/add.tool';
6
12