Skip to content

Add comprehensive test coverage #1

@BekahHW

Description

@BekahHW

Description

Currently, RepoReady has zero test files despite having Jest configured in package.json and @types/jest installed. This is a critical gap that needs to be addressed to ensure code reliability and make the project more contributor-friendly.

Current State

  • ✅ Jest is configured in package.json with script "test": "jest"
  • ✅ Jest dependencies are installed (jest, @types/jest)
  • ❌ No test files exist in the project
  • ❌ No test directory structure

Acceptance Criteria

Test Structure

  • Create src/__tests__/ or tests/ directory
  • Add Jest configuration file (jest.config.js)
  • Create test files for all major components:
    • src/evaluator/index.test.ts
    • src/evaluator/criteria.test.ts
    • src/utils/github.test.ts
    • src/utils/display.test.ts
    • src/commands/evaluate.test.ts
    • src/commands/create.test.ts

Test Coverage

  • Achieve minimum 80% code coverage
  • Test all evaluation criteria functions
  • Test score calculation logic
  • Test rating determination
  • Mock GitHub API calls for consistent testing

CI Integration

  • Update npm test to work properly
  • Add coverage reporting
  • Include test results in future CI pipeline

Implementation Suggestions

Sample Test Structure

// src/__tests__/evaluator/criteria.test.ts
import { evaluationCriteria, calculateRating } from '../evaluator/criteria';
import { RepositoryInfo } from '../types';

describe('Evaluation Criteria', () => {
  describe('calculateRating', () => {
    it('should return "Excellent" for 90-100%', () => {
      expect(calculateRating(95)).toBe('Excellent');
    });
    
    it('should return "Good" for 75-89%', () => {
      expect(calculateRating(80)).toBe('Good');
    });
    
    // ... more tests
  });
});

Mock Repository Data

const mockRepo: RepositoryInfo = {
  owner: 'test-owner',
  repo: 'test-repo',
  name: 'test-repo',
  description: 'A test repository for unit testing',
  topics: ['test', 'typescript'],
  hasReadme: true,
  hasContributing: false,
  // ... other properties
};

Files to Focus On

  • src/evaluator/criteria.ts (158 lines - core scoring logic)
  • src/utils/github.ts (317 lines - API interactions)
  • src/evaluator/index.ts (33 lines - main evaluator)

Benefits

  • 🛡️ Prevents regressions when adding new features
  • 🚀 Makes it safer for new contributors to make changes
  • 📊 Provides confidence in the scoring algorithm
  • 🔍 Helps identify edge cases and bugs

Resources

Estimated Effort

Medium - Requires understanding of the codebase and testing patterns, but well-defined scope.


This issue is perfect for contributors who want to learn about testing patterns and ensure code quality! 🧪

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