We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/s2005/wcli0'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
unit-test-task-12.md•2.36 kB
# Unit Test Task 12: Increase Coverage for Configuration and Path Validation
## Priority
MEDIUM - Improve reliability without disrupting existing functionality.
## Description
This task adds new unit tests to cover critical configuration and path validation code that currently has relatively low coverage. The goal is to bring overall statement coverage above **82%** and branch coverage above **75%** while ensuring the existing test suite remains stable.
## Scope
- Test `validateConfig` helper in `src/utils/config.ts` for invalid values and error cases.
- Test `createDefaultConfig` to ensure the file is written correctly without runtime validation functions.
- Expand `toolDescription.details.test.ts` so each shell type is exercised and path format notes appear.
- Add edge-case tests for `validateWorkingDirectory` in `src/utils/pathValidation.ts` including WSL and GitBash conversions and empty `allowedPaths` errors.
- Add additional cases for `mergeConfigs` in `src/utils/config.ts` when user configs enable only subsets of shells or omit sections.
## Files to Modify/Create
- `tests/configValidation.test.ts` (new)
- `tests/defaultConfig.test.ts` (new)
- `tests/toolDescription.details.test.ts` (update)
- `tests/pathValidation.edge.test.ts` (new)
- `tests/configMerge.test.ts` (new)
## Expected Coverage After Implementation
- Statements: **≈82–84%**
- Branches: **≈75–77%**
- `src/utils/config.ts` line coverage above **80%**
- `src/utils/pathValidation.ts` line coverage above **85%**
## Acceptance Criteria
1. All existing tests continue to pass (`npm test`).
2. New tests cover the scenarios listed in the Scope section.
3. Overall coverage meets the expected percentages when running `npm run test:coverage`.
4. Documentation for added tests is provided in `TEST_DESCRIPTIONS.md`.
5. No regressions or breaking changes in other unit tests.
## Implementation Notes
- Use temporary directories via `fs.mkdtempSync` for file‑writing tests.
- Mock shell configurations where necessary to isolate validation logic.
- Follow existing test patterns for mocking and cleanup.
- Document the added tests and update coverage numbers in `README` if necessary.
## Dependencies
- None.
## Related Files
- `src/utils/config.ts`
- `src/utils/pathValidation.ts`
- `src/toolDescription.ts`
- `tests/toolDescription.details.test.ts`