Files
claude-task-master/tests
Eyal Toledano d63964a10e refactor: Improve update-subtask, consolidate utils, update config
This commit introduces several improvements and refactorings across MCP tools, core logic, and configuration.

**Major Changes:**

1.  **Refactor updateSubtaskById:**
    - Switched from generateTextService to generateObjectService for structured AI responses, using a Zod schema (subtaskSchema) for validation.
    - Revised prompts to have the AI generate relevant content based on user request and context (parent/sibling tasks), while explicitly preventing AI from handling timestamp/tag formatting.
    - Implemented **local timestamp generation (new Date().toISOString()) and formatting** (using <info added on ...> tags) within the function *after* receiving the AI response. This ensures reliable and correctly formatted details are appended.
    - Corrected logic to append only the locally formatted, AI-generated content block to the existing subtask.details.

2.  **Consolidate MCP Utilities:**
    - Moved/consolidated the withNormalizedProjectRoot HOF into mcp-server/src/tools/utils.js.
    - Updated MCP tools (like update-subtask.js) to import withNormalizedProjectRoot from the new location.

3.  **Refactor Project Initialization:**
    - Deleted the redundant mcp-server/src/core/direct-functions/initialize-project-direct.js file.
    - Updated mcp-server/src/core/task-master-core.js to import initializeProjectDirect from its correct location (./direct-functions/initialize-project.js).

**Other Changes:**

-   Updated .taskmasterconfig fallback model to claude-3-7-sonnet-20250219.
-   Clarified model cost representation in the models tool description (taskmaster.mdc and mcp-server/src/tools/models.js).
2025-05-02 17:48:59 -04:00
..
2025-04-09 00:30:05 +02:00

Task Master Test Suite

This directory contains tests for the Task Master CLI. The tests are organized into different categories to ensure comprehensive test coverage.

Test Structure

  • unit/: Unit tests for individual functions and components
  • integration/: Integration tests for testing interactions between components
  • e2e/: End-to-end tests for testing complete workflows
  • fixtures/: Test fixtures and sample data

Running Tests

To run all tests:

npm test

To run tests in watch mode (for development):

npm run test:watch

To run tests with coverage reporting:

npm run test:coverage

Testing Approach

Unit Tests

Unit tests focus on testing individual functions and components in isolation. These tests should be fast and should mock external dependencies.

Integration Tests

Integration tests focus on testing interactions between components. These tests ensure that components work together correctly.

End-to-End Tests

End-to-end tests focus on testing complete workflows from a user's perspective. These tests ensure that the CLI works correctly as a whole.

Test Fixtures

Test fixtures provide sample data for tests. Fixtures should be small, focused, and representative of real-world data.

Mocking

For external dependencies like file system operations and API calls, we use mocking to isolate the code being tested.

  • File system operations: Use mock-fs to mock the file system
  • API calls: Use Jest's mocking capabilities to mock API responses

Test Coverage

We aim for at least 80% test coverage for all code paths. Coverage reports can be generated with:

npm run test:coverage