A web application built with React that allows users to connect to a public GitHub repository, select code files, and use AI to automatically generate test case summaries and full test code using the Google Gemini API.
- GitHub Integration: Fetches and displays the file tree of any public GitHub repository.
- File Selection: Intuitive file explorer to select one or more relevant code files (
.js
,.jsx
,.ts
,.tsx
) for analysis. - AI-Powered Summary Generation: Uses the Gemini API to analyze the content of selected files and suggest a list of relevant test case summaries.
- AI-Powered Code Generation: Generates complete, ready-to-use test code (Jest & React Testing Library) based on a selected summary.
- Step-by-Step UI: Clean, multi-step interface to guide the user through the process.
- Responsive Design: Modern, mobile-friendly UI built with Tailwind CSS.
- Frontend: React, Vite
- Styling: Tailwind CSS
- Icons: Lucide React
- AI: Google Gemini API
- APIs: GitHub REST API
Follow these steps to run the project on your local machine.
git clone <your-repository-url>
cd test-case-generator
npm install
This project requires a Google Gemini API key to function.
- Get an API Key: Go to Google AI Studio and create a free API key.
- Create an Environment File: In the root of your project, create a file named
.env
. - Add Your Key: Add the following line to your
.env
file, replacingYOUR_API_KEY_HERE
with your key:VITE_GEMINI_API_KEY=YOUR_API_KEY_HERE
- Update
.gitignore
: Add.env
to your.gitignore
file to keep your key private.
npm run dev
The application should now be running at: http://localhost:5173
- Enter a GitHub URL: On the first screen, enter the URL of a public GitHub repository (e.g.,
https://github.com/facebook/react
) and click "Fetch Files". - Select Files: The app will display a list of relevant code files. Select the files you want to analyze and click "Generate Summaries".
- Choose a Test Case: The AI will return a list of suggested test case summaries. Click on a summary you'd like to generate code for.
- Generate Code: Click "Generate Code" to create full test code based on your selection.
- Copy and Use: Copy the generated code and add it to your project’s test suite. Use the "Back" or "Start Over" buttons to navigate.
- GitHub Authentication: Support for OAuth2 to allow analyzing private repositories.
- Create Pull Request: Automatically fork the repo, commit the test file, and open a PR on GitHub.
- Framework Selection: Let users choose testing frameworks like Cypress, Playwright, or PyTest.