* fix: normalize task IDs to numbers on load to fix comparison issues When tasks.json contains string IDs (e.g., "5" instead of 5), task lookups fail because the code uses parseInt() and strict equality (===) for comparisons. This fix normalizes all task and subtask IDs to numbers when loading the JSON, ensuring consistent comparisons throughout the codebase without requiring changes to multiple comparison locations. Fixes task not found errors when using string IDs in tasks.json. * Added test * Don't mess up formatting * Fix formatting once and for all * Update scripts/modules/utils.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update scripts/modules/utils.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update scripts/modules/utils.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: normalize task IDs to numbers on load to fix comparison issues - Added normalizeTaskIds function to convert string IDs to numbers - Applied normalization in readJSON for all code paths - Fixed set-task-status, add-task, and move-task to normalize IDs when working with raw data - Exported normalizeTaskIds function for use in other modules - Added test case for string ID normalization 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Simplified implementation * refactor: normalize IDs once when loading JSON instead of scattered calls - Normalize all tags' data when creating _rawTaggedData in readJSON - Add support for handling malformed dotted subtask IDs (e.g., "5.1" -> 1) - Remove redundant normalizeTaskIds calls from set-task-status, add-task, and move-task - Add comprehensive test for mixed ID formats (string IDs and dotted notation) - Cleaner, more maintainable solution that normalizes IDs at load time 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: run format to resolve CI issues --------- Co-authored-by: Carl Mercier <carl@carlmercier.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
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 componentsintegration/: Integration tests for testing interactions between componentse2e/: End-to-end tests for testing complete workflowsfixtures/: 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-fsto 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