A Chrome extension that adds a "Generate Unit Test" button to GitHub file pages, allowing you to automatically generate unit tests for selected functions using GitHub Copilot or AI APIs.
No API key configuration needed! The extension now integrates directly with GitHub Copilot, using your existing subscription to generate unit tests.
- 🤖 GitHub Copilot Integration: Uses your existing GitHub Copilot subscription (no extra API keys needed)
- 🔍 Smart Function Detection: Automatically detects if selected code is a function
- 🎯 Context-Aware: Analyzes surrounding code for better test generation
- 📁 Smart Path Generation: Suggests appropriate test file paths based on project structure
- 🌐 Multi-Language Support: Supports JavaScript, TypeScript, Python, Java, C#, Go, PHP, Ruby, Rust, and more
- ⚡ GitHub Integration: Seamlessly integrates with GitHub's UI
- 🔄 Multiple Modes: Copilot chat, editor integration, or template generation
- Clone or download this repository
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" in the top right
- Click "Load unpacked" and select the extension directory
- Start using with GitHub Copilot (no configuration needed!)
- Navigate to any file on GitHub
- Select a function or code block you want to test
- Click the "Generate Unit Test" button that appears
- The extension will automatically:
- Open GitHub Copilot chat, OR
- Insert test generation prompts in the editor, OR
- Show a template dialog with guidance
No API key configuration required - uses your existing GitHub Copilot subscription!
If you prefer to use external AI services, you can still configure API keys:
- Click the extension icon in the Chrome toolbar
- Select your preferred AI provider (OpenAI or Anthropic)
- Choose the model you want to use
- Enter your API key
- Click "Save Configuration"
- OpenAI: Get your API key from OpenAI Platform
- Anthropic: Get your API key from Anthropic Console
The extension automatically detects the programming language and generates appropriate tests using the recommended testing framework:
- JavaScript/TypeScript: Jest
- Python: pytest
- Java: JUnit 5
- C#: xUnit
- Go: Go testing
- PHP: PHPUnit
- Ruby: RSpec
- Rust: Rust test framework
- Automatically opens GitHub Copilot chat
- Sends structured test generation prompts
- Provides complete test code with proper setup
- Inserts test generation comments in GitHub's editor
- Uses Copilot's code completion for test generation
- Perfect for in-browser editing workflow
- Provides suggested test file paths
- Generates language-specific test templates
- Includes step-by-step instructions for manual setup
The generated tests typically include:
- ✅ Happy path scenarios
- ✅ Edge cases and boundary conditions
- ✅ Error handling tests
- ✅ Proper mocking of dependencies
- ✅ Descriptive test names and comments
- ✅ Language-specific best practices
- Uses your existing GitHub authentication
- No additional data storage required
- All interactions through GitHub's official Copilot interface
- API keys are stored locally in Chrome's storage
- No data is sent to our servers
- All communication is directly between your browser and the chosen AI service
- Selected code is only sent to the AI service you configure
- Install the extension (see Installation section above)
- Go to any GitHub repository file
- Select a function - make sure to select the complete function code
- Click "Generate Unit Test" - button appears automatically
- Let Copilot generate your tests - no setup required!
For detailed usage instructions, see USER_GUIDE.md
├── manifest.json # Extension manifest
├── content.js # Main content script for GitHub integration
├── background.js # Background script for AI API calls
├── popup.html # Extension popup UI
├── popup.js # Popup functionality
├── styles.css # Styling for modals and buttons
├── icons/ # Extension icons
└── README.md # This file
No build process required. This is a vanilla JavaScript extension that works directly in Chrome.
- Load the extension in developer mode
- Navigate to any GitHub repository file
- Select some function code
- Test the generation functionality
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - see LICENSE file for details
- GitHub Copilot integration
- Support for more AI providers
- Batch test generation for entire files
- Integration with GitHub's create file API
- Support for more programming languages
- Custom test templates
- Test coverage analysis
- GitHub Enterprise support
- Make sure you're on a GitHub file page (not directory listing)
- Check that the extension is enabled
- Refresh the page
- Verify your API key is correct
- Check your API quota/billing
- Ensure you have the right permissions for the selected model
- Try selecting more context around the function
- Use a more powerful model (GPT-4 vs GPT-3.5)
- Ensure the selected code is actually a complete function
If you encounter issues or have suggestions, please open an issue on GitHub.