Skip to content

Add comprehensive test suite for RepoReady CLI #22

@continue

Description

@continue

Summary

Add a comprehensive test suite to ensure code quality and maintainability for the RepoReady CLI tool. Currently, the project has Jest configured in package.json but no test files exist.

Background

The project includes:

  • TypeScript codebase with multiple modules
  • GitHub API integration via Octokit
  • CLI commands (evaluate, create)
  • Repository evaluation logic with scoring criteria
  • Display utilities and user interactions

Current testing setup:

  • Jest is configured as a dev dependency
  • npm test script exists in package.json
  • tsconfig.json excludes **/*.test.ts files
  • No test files currently exist in the codebase

Proposed Solution

1. Test Infrastructure Setup

  • Configure Jest for TypeScript (jest.config.js)
  • Add test script configurations (unit, integration, coverage)
  • Set up test utilities and helpers
  • Configure code coverage thresholds

2. Unit Tests

Evaluator Module (src/evaluator/)

  • criteria.ts
    • Test each evaluation criteria check function
    • Test edge cases (empty strings, null values, boundary conditions)
    • Test calculateRating() with all percentage ranges
    • Test generateRecommendations() with various failed criteria combinations
  • index.ts (RepositoryEvaluator)
    • Test evaluation scoring calculation
    • Test result aggregation
    • Mock repository data scenarios

Utils Module (src/utils/)

  • github.ts (GitHubService)
    • Mock Octokit responses
    • Test getRepositoryInfo() with various repo configurations
    • Test file existence checking logic
    • Test organization community file fallback detection
    • Test createRepository() success and error cases
    • Test error handling for API failures
  • display.ts (DisplayUtils)
    • Test output formatting functions
    • Test error message display
    • Snapshot testing for console output
  • intro.ts (HeaderUtils)
    • Test header generation
    • Verify ASCII art formatting

Commands Module (src/commands/)

  • evaluate.ts
    • Test argument parsing
    • Test error handling (invalid repo format, not found, rate limits)
    • Mock GitHub API calls
    • Test token handling
  • create.ts
    • Test repository creation flow
    • Test validation logic
    • Test interactive prompts (using mocked inquirer)
    • Test optional evaluation after creation

3. Integration Tests

  • Test full evaluation workflow end-to-end
  • Test repository creation with GitHub API (optional, could use test account)
  • Test CLI command execution with different argument combinations

4. Test Data & Mocks

  • Create fixture data for common repository scenarios
    • Excellent repository (90%+)
    • Good repository (75-89%)
    • Fair repository (60-74%)
    • Needs work repository (40-59%)
    • Not ready repository (<40%)
  • Mock Octokit API responses
  • Mock file system operations
  • Mock user input prompts

5. Coverage Goals

  • Aim for 80%+ code coverage
  • Focus on critical paths and business logic
  • Add coverage reporting to CI/CD pipeline

Implementation Approach

  1. Phase 1: Infrastructure

    • Set up Jest configuration
    • Create test utilities and mock factories
    • Add basic test structure
  2. Phase 2: Core Logic Tests

    • Test evaluator criteria (highest priority)
    • Test scoring calculations
    • Test GitHub service utilities
  3. Phase 3: Command Tests

    • Test CLI commands with mocked dependencies
    • Test user interaction flows
  4. Phase 4: Integration & Coverage

    • Add integration tests
    • Improve coverage to meet thresholds
    • Document testing practices

Testing Tools & Libraries

  • Jest: Test framework (already installed)
  • @types/jest: TypeScript types (already installed)
  • ts-jest: TypeScript preprocessor for Jest
  • nock (optional): HTTP mocking for API calls
  • Mock strategies: Jest's built-in mocking for Octokit

Expected Outcomes

  • Comprehensive test coverage (80%+)
  • Confidence in refactoring and new features
  • Automated testing in CI/CD pipeline
  • Documented testing patterns for contributors
  • Reduced bugs in production releases

Acceptance Criteria

  • All proposed test files created
  • Tests pass successfully (npm test)
  • Code coverage meets 80% threshold
  • Tests are documented and maintainable
  • CI/CD pipeline includes test execution
  • CONTRIBUTING.md updated with testing guidelines

Additional Notes

  • Consider adding pre-commit hooks (husky) to run tests
  • Add test execution to GitHub Actions workflow
  • Document how to run tests in README.md
  • Consider adding E2E tests for CLI in a separate phase

Related Files

  • src/evaluator/criteria.ts - Evaluation logic
  • src/evaluator/index.ts - Repository evaluator
  • src/utils/github.ts - GitHub API service
  • src/commands/evaluate.ts - Evaluate command
  • src/commands/create.ts - Create command
  • package.json - Test scripts
  • tsconfig.json - TypeScript config

Labels: enhancement, testing, good first issue, help wanted

Co-authored-by: bekahhw rhawrot@gmail.com

Generated with Continue

Co-Authored-By: Continue noreply@continue.dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions