VOOZH about

URL: https://deepwiki.com/Digilac/simap-mcp/6.4-testing

⇱ Testing | Digilac/simap-mcp | DeepWiki


Loading...
Menu

Testing

This document explains the testing strategy, test organization, execution methods, and requirements for the simap-mcp server. Testing is a core requirement for all contributions to ensure the reliability of tool schemas, API parameter mapping, and response formatting.


Testing Strategy

The simap-mcp project enforces mandatory testing for all new features and tools. The strategy is built around four pillars:

  1. Schema Validation: Ensuring zod schemas correctly accept valid inputs and reject malformed ones, such as enforcing string lengths, UUID formats, or regex patterns tests/tools/get-tender-details.test.ts41-84
  2. Query Parameter Building: Verifying that tool inputs are correctly mapped to SIMAP API query parameters, including handling array serialization and scalar values tests/api/client.test.ts38-66
  3. Response Formatting: Confirming that API data is transformed into readable Markdown for the MCP client, using fixtures to simulate real API payloads tests/tools/get-tender-details.test.ts86-120 tests/utils/formatting.test.ts128-191
  4. Logic & Utility Verification: Testing core infrastructure like rate limiting and error handling to ensure system stability tests/api/rate-limiter.test.ts8-22

Natural Language to Code Mapping: Testing Entities

The following diagram bridges the conceptual testing requirements to the specific code entities and files used in the testing suite.

Title: Mapping Requirements to Code Entities


Sources: tests/tools/search-cpv-codes.test.ts8-9 tests/api/rate-limiter.test.ts6 tests/api/client.test.ts8-10 tests/utils/formatting.test.ts9-15


Test Organization

Directory Structure

Test files mirror the src/ directory structure to maintain a clear 1:1 relationship between implementation and verification tests/tools/get-tender-details.test.ts9-12

Source FileTest File
src/tools/codes/search-cpv-codes.tstests/tools/search-cpv-codes.test.ts
src/tools/get-tender-details.tstests/tools/get-tender-details.test.ts
src/api/rate-limiter.tstests/api/rate-limiter.test.ts
src/api/client.tstests/api/client.test.ts
src/utils/formatting.tstests/utils/formatting.test.ts

Code Flow: Test Execution Path

Title: Internal Test Logic Flow


Sources: tests/tools/search-cpv-codes.test.ts11-42 tests/api/client.test.ts38-42 tests/utils/formatting.test.ts87-126 tests/utils/formatting.test.ts128-132


Tool Test Requirements

1. Schema Validation

Tests must verify that the zod schema defined for each tool enforces constraints like string length, UUID formats, and language defaults.

2. Query Parameter Building

Tests verify that the SimapClient and tool handlers correctly serialize data for the SIMAP API.

3. Response Formatting

Tests ensure that the data returned to the user is transformed into high-quality Markdown.

4. Infrastructure and Utility Testing

  • Formatting Utilities: As of v1.2.3, formatting.test.ts provides direct unit coverage for escapeInlineCode, ensuring that backslashes and backticks are escaped to prevent Markdown breakage (e.g., \ becomes \\\\\\ to preserve the escape in Markdown) tests/utils/formatting.test.ts57-85
  • Rate Limiting: The SlidingWindowRateLimiter is tested using fake timers to ensure it correctly handles concurrent acquires and serves them in FIFO order tests/api/rate-limiter.test.ts54-72
  • Network Resilience: SimapClient tests mock fetch to verify behavior during 404/500 errors and request timeouts tests/api/client.test.ts110-158
  • Debug Logging: Tests verify that verbose logging (using and markers) is triggered only when SIMAP_MCP_DEBUG is set tests/api/client.test.ts191-206

Running Tests

The project uses vitest as the primary test runner.

CommandAction
npm testRuns all tests once.
npm run test:watchRuns tests in watch mode for active development.
npm run typecheckValidates TypeScript types across the entire project including test files.

Sources: tests/tools/search-cpv-codes.test.ts5 tests/api/rate-limiter.test.ts5 tests/api/client.test.ts6