|
| 1 | +# CLI Tests |
| 2 | + |
| 3 | +## Running Tests |
| 4 | + |
| 5 | +```bash |
| 6 | +# Run all tests |
| 7 | +npm test |
| 8 | + |
| 9 | +# Run in watch mode (useful for test file changes; won't work on CLI source changes without rebuild) |
| 10 | +npm run test:watch |
| 11 | + |
| 12 | +# Run specific test file |
| 13 | +npm run test:cli # cli.test.ts |
| 14 | +npm run test:cli-tools # tools.test.ts |
| 15 | +npm run test:cli-headers # headers.test.ts |
| 16 | +npm run test:cli-metadata # metadata.test.ts |
| 17 | +``` |
| 18 | + |
| 19 | +## Test Files |
| 20 | + |
| 21 | +- `cli.test.ts` - Basic CLI functionality: CLI mode, environment variables, config files, resources, prompts, logging, transport types |
| 22 | +- `tools.test.ts` - Tool-related tests: Tool discovery, JSON argument parsing, error handling, prompts |
| 23 | +- `headers.test.ts` - Header parsing and validation |
| 24 | +- `metadata.test.ts` - Metadata functionality: General metadata, tool-specific metadata, parsing, merging, validation |
| 25 | + |
| 26 | +## Helpers |
| 27 | + |
| 28 | +The `helpers/` directory contains shared utilities: |
| 29 | + |
| 30 | +- `cli-runner.ts` - Spawns CLI as subprocess and captures output |
| 31 | +- `test-mcp-server.ts` - Standalone stdio MCP server script for stdio transport testing |
| 32 | +- `instrumented-server.ts` - In-process MCP test server for HTTP/SSE transports with request recording |
| 33 | +- `assertions.ts` - Custom assertion helpers for CLI output validation |
| 34 | +- `fixtures.ts` - Test config file generators and temporary directory management |
| 35 | + |
| 36 | +## Notes |
| 37 | + |
| 38 | +- Tests run in parallel across files (Vitest default) |
| 39 | +- Tests within a file run sequentially (we have isolated config files and ports, so we could get more aggressive if desired) |
| 40 | +- Config files use `crypto.randomUUID()` for uniqueness in parallel execution |
| 41 | +- HTTP/SSE servers use dynamic port allocation to avoid conflicts |
| 42 | +- Coverage is not used because much of the code that we want to measure is run by a spawned process, so it can't be tracked by Vitest |
| 43 | +- /sample-config.json is no longer used by tests - not clear if this file serves some other purpose so leaving it for now |
| 44 | +- All tests now use built-in MCP test servers, there are no external dependencies on servers from a registry |
0 commit comments