-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
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 testscript exists in package.json- tsconfig.json excludes
**/*.test.tsfiles - 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
-
Phase 1: Infrastructure
- Set up Jest configuration
- Create test utilities and mock factories
- Add basic test structure
-
Phase 2: Core Logic Tests
- Test evaluator criteria (highest priority)
- Test scoring calculations
- Test GitHub service utilities
-
Phase 3: Command Tests
- Test CLI commands with mocked dependencies
- Test user interaction flows
-
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 logicsrc/evaluator/index.ts- Repository evaluatorsrc/utils/github.ts- GitHub API servicesrc/commands/evaluate.ts- Evaluate commandsrc/commands/create.ts- Create commandpackage.json- Test scriptstsconfig.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
Labels
No labels