Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 28, 2025

This PR implements a comprehensive testing infrastructure for the Task Board plugin, following the approach used by the obsidian-tasks plugin as requested in the issue.

What's Added

Testing Framework:

  • Jest with TypeScript support and ts-jest preset
  • jsdom environment for DOM testing
  • Proper mocking of Obsidian APIs to avoid runtime dependencies
  • Test setup with custom matchers from @testing-library/jest-dom

Test Coverage (62 tests total):

  • TaskRegularExpressions (25 tests): Task parsing regex patterns, checkboxes, hash tags, block links
  • TaskItem Interfaces (14 tests): Data structure validation, priority mappings, JSON cache formats
  • CheckBoxUtils (23 tests): Checkbox state switching, task validation, Obsidian settings

Infrastructure:

  • Test scripts: npm test, npm run test:watch, npm run test:coverage
  • Jest configuration optimized for Obsidian plugin development
  • GitHub Actions integration - tests now run before releases
  • Comprehensive documentation in tests/README.md

Example Test Output

PASS tests/utils/TaskRegularExpressions.test.ts
  TaskRegularExpressions
    ✓ should parse basic task
    ✓ should parse indented task  
    ✓ should match hash tags correctly
    ✓ should handle various checkbox states

PASS tests/utils/CheckBoxUtils.test.ts
  CheckBoxUtils
    ✓ should switch checkbox states correctly
    ✓ should detect completed tasks
    ✓ should validate task line format

Test Suites: 3 passed, 3 total
Tests: 62 passed, 62 total

Benefits

This testing infrastructure will significantly reduce manual testing time by automatically validating:

  • Task parsing logic and regular expressions
  • Checkbox state transitions and validation
  • Data structure integrity and type safety
  • Configuration handling and edge cases

The tests focus on core functionality that's difficult to manually test and prone to regressions, ensuring the plugin remains stable as new features are added.

Fixes #362.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 28, 2025 06:37
- Add Jest testing framework with TypeScript support
- Create test infrastructure with proper mocking for Obsidian APIs
- Add tests for TaskRegularExpressions (parsing, checkboxes, hash tags)
- Add tests for TaskItem interfaces and priority constants
- Add tests for CheckBoxUtils (state switching, validation)
- Update package.json with test scripts (test, test:watch, test:coverage)
- Update GitHub Actions workflow to run tests before release
- Add test coverage to .gitignore
- Add comprehensive README for testing approach

Co-authored-by: tu2-atmanand <[email protected]>
Copilot AI changed the title [WIP] Chore : Add few tests for this project Add comprehensive test suite with Jest following obsidian-tasks testing approach Aug 28, 2025
Copilot AI requested a review from tu2-atmanand August 28, 2025 06:48
@tu2-atmanand tu2-atmanand added the chore This is not directly related to the project but more of a management of the project. label Nov 20, 2025
@github-project-automation github-project-automation bot moved this to Future Ideas in Task Board Dev Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore This is not directly related to the project but more of a management of the project.

Projects

Status: Future Ideas

Development

Successfully merging this pull request may close these issues.

Chore : Add few tests for this project

2 participants