{"id":19846628,"url":"https://github.com/fayez-nazzal/testgpt","last_synced_at":"2025-05-07T19:02:15.124Z","repository":{"id":65956637,"uuid":"603395580","full_name":"fayez-nazzal/TestGPT","owner":"fayez-nazzal","description":"Your AI testing companion that writes tests on your behalf, automated to get you to build and ship faster without sacrificing unit tests.","archived":false,"fork":false,"pushed_at":"2023-09-14T20:08:43.000Z","size":1618,"stargazers_count":133,"open_issues_count":1,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T19:01:51.527Z","etag":null,"topics":["command-line-tool","gpt-3-5-turbo","gpt-4","testing","unit-testing"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/testgpt","language":"Svelte","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fayez-nazzal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-18T11:34:09.000Z","updated_at":"2025-02-23T11:17:32.000Z","dependencies_parsed_at":"2024-11-12T13:12:14.974Z","dependency_job_id":"8cb00c4b-9f9b-458a-a1c0-c9640b486b42","html_url":"https://github.com/fayez-nazzal/TestGPT","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":0.2777777777777778,"last_synced_commit":"51000f5d72cfd6ba15646db6ca78a3b264c93fbb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fayez-nazzal%2FTestGPT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fayez-nazzal%2FTestGPT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fayez-nazzal%2FTestGPT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fayez-nazzal%2FTestGPT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fayez-nazzal","download_url":"https://codeload.github.com/fayez-nazzal/TestGPT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252940907,"owners_count":21828769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line-tool","gpt-3-5-turbo","gpt-4","testing","unit-testing"],"created_at":"2024-11-12T13:12:00.814Z","updated_at":"2025-05-07T19:02:14.978Z","avatar_url":"https://github.com/fayez-nazzal.png","language":"Svelte","funding_links":[],"categories":[],"sub_categories":[],"readme":"![TestGPT - Logo Cover](https://github.com/fayez-nazzal/TestGPT/assets/49946791/77ec722a-dfb6-4f49-a4b1-d4b659219765)\n\nYour AI testing companion that writes tests on your behalf, automated to get you to build and ship faster without sacrificing tests.\n\n\u003cbr /\u003e\n\n\u003cimg src=\"media/show.gif\" alt=\"TestGPT Show\" /\u003e\n\n\u003cbr /\u003e\n\u003chr /\n\n\u003cbr /\u003e\n\nBy default, TestGPT will use the OpenAI gpt-3.5-turbo-16k model, but you can use gpt-4, or any other model you want.\n\n\n\u003ch2\u003e    \u003cimg style=\"padding-right: 4px;\" src=\"https://storage.googleapis.com/fayeznazzal/TestGPT-logo.svg\" width=\"24px\" height=\"24px\" /\u003e\n Installation\n\u003c/h2\u003e\n\n\u003ch3\u003e    \u003cimg style=\"padding-right: 4px;\" src=\"https://storage.googleapis.com/fayeznazzal/TestGPT-logo.svg\" width=\"24px\" height=\"16px\" /\u003e\n VSCode Extension\n\u003c/h3\u003e\n\nAn extension is available on the [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=FayezNazzal.testgpt)\n\nor install directly by entering this command in the VSCode command palette (Command+P) / (Ctrl+P):\n\n```\n   ext install fayeznazzal.testgpt\n```\n\n\u003ch3\u003e    \u003cimg style=\"padding-right: 4px;\" src=\"https://storage.googleapis.com/fayeznazzal/TestGPT-logo.svg\" width=\"24px\" height=\"16px\" /\u003e\n CLI Tool\n\u003c/h3\u003e\n\nTo install the CLI tool, follow those steps\n\n1. Install TestGPT by running one of these commands:\n\n   ```zsh\n   # Install globally\n   npm install -g testgpt@latest\n\n   # OR install locally in your project\n   npm install testgpt@latest\n   ```\n\n2. **Get your OpenAI API Key** by requesting access to the [OpenAI API](https://openai.com/api/) and obtaining your [API key](https://platform.openai.com/account/api-keys).\n\n   Then export it based on your OS:\n\n   - **macOS or Linux:** Add the following line to .zshrc or .bashrc in your home directory:\n\n     ```zsh\n     export OPENAI_API_KEY=\"Your OpenAI API Key.\"\n     ```\n\n     Then run the command:\n\n     ```zsh\n     source ~/.zshrc\n     ```\n\n   - **Windows:** Go to System -\u003e Settings -\u003e Advanced -\u003e Environment Variables, click New under System Variables, and create a new entry with the key `OPENAI_API_KEY` and your OpenAI API Key as the value.\n\n\u003ch2\u003e    \u003cimg style=\"padding-right: 4px;\" src=\"https://storage.googleapis.com/fayeznazzal/TestGPT-logo.svg\" width=\"24px\" height=\"24px\" /\u003e\n Usage\n\u003c/h2\u003e\n\n### \u003cimg style=\"padding-right: 4px;\" src=\"https://storage.googleapis.com/fayeznazzal/TestGPT-logo.svg\" width=\"16px\" height=\"16px\" /\u003e Universal / Plug and Play\n\nHere's a simple form of a test generation command:\n\n```zsh\ntestgpt -i ./component.tsx -m gpt4\n# Creates: ./component.test.tsx\n```\n\nWith more options, comes more power! You can easily specify target techs, tips, and specify a custom GPT model, along with other options. Here is a breakdown table:\n\n\u003cdiv style=\"display: flex; flex-direction: column; gap: 8px;\"\u003e\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--inputFile\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-i\u003c/span\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n   \u003cspan style=\"color: #ff8b8b\"\u003e[ Required ]\u003c/span\u003e\n \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n   Path for the input file to be tested (e.g. `./Button.tsx`).\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--outputFile\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-o\u003c/span\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n   \u003cspan style=\"color: #bbbb8b\"\u003e[ Default: {inputFile}.test.{extension} ]\u003c/span\u003e\n \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n   Path for the output file where the generated tests will be written (e.g. `./Button.spec.tsx`). If not provided, the output file will be the same as the input file, but with `.test` added before the extension.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--apiKey\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-k\u003c/span\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n   \u003cspan style=\"color: #bbbb8b\"\u003e[ Default: OPENAI_API_KEY Env ]\u003c/span\u003e\n \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n   OpenAI API key. If not provided, it will be taken from the `OPENAI_API_KEY` environment variable. If using an API other than OpenAI, currently, this option will be ignored.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--model\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-m\u003c/span\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n   \u003cspan style=\"color: #bbbb8b\"\u003e[ Default: gpt-3.5-turbo-16k ]\u003c/span\u003e\n \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n   GPT model to be used for generating tests. If using an API other than OpenAI, currently, this option will be ignored.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--stream\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-s\u003c/span\u003e\n   \n \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n      Stream the response using OpenAI streaming feature. If using an API other than OpenAI, currently, this option will be ignored.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--systemMessage\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-y\u003c/span\u003e\n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n      System message to be used for generating tests.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--promptTemplate\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-p\u003c/span\u003e\n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n      Prompt template to be used for generating tests. You can substitute the following variables in the template:\n        \u003cul\u003e\n         \u003cli\u003efileName: The name of the file being tested.\u003c/li\u003e\n         \u003cli\u003econtent: The content of the file being tested.\u003c/li\u003e\n         \u003cli\u003etechs: The technologies to be used.\u003c/li\u003e\n         \u003cli\u003einstructions: General Instructions for generating tests.\u003c/li\u003e\n        \u003c/ul\u003e\n\nTo substitute a variable, use the following syntax: `{variableName}`\n\nHere is an example:\n\n```js\nPlease provide unit tests for the file {fileName} using {techs}\n{instructions}\n\nPlease begin your response with \\`\\`\\` and end it with \\`\\`\\` directly.\n\nHere is the file content:\n\\`\\`\\`{content}\\`\\`\\`\n```\n\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--techs\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-t\u003c/span\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: #bbbb8b\"\u003e[ Default: Auto Detected ]\u003c/span\u003e\n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n      The technologies to be used.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--examples\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-e\u003c/span\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n      Example snippets to guide the AI test generation process.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--moduleEndpoint\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-e\u003c/span\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n      An API endpoint for a custom model to send the request to. Only use this if you have a custom model deployed and you want to use it instead of OpenAI.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--instructions\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-n\u003c/span\u003e\n    \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n      General Instructions for generating tests.\n   \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n   \u003csummary\u003e\n   \u003cb\u003e--config\u003c/b\u003e\n    \u003cspan style=\"margin: 0 6px\"\u003e|\u003c/span\u003e \n    \u003cspan style=\"color: currentColor\"\u003e-c\u003c/span\u003e\n    \n   \u003c/summary\u003e\n   \n   \u003cdiv style=\"margin-left: 12px\"\u003e\n      Path to config file.\n   \u003c/div\u003e\n\u003c/details\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\nHere is an example command that uses more options like those mentioned above:\n\n```zsh\ntestgpt -i ./Button.tsx -o ./Button.spec.tsx -m gpt-4 --techs \"jest, testing-library\" --apiKey \"Your OpenAI API Key\"\n```\n\n### \u003cimg style=\"padding-right: 4px;\" src=\"https://storage.googleapis.com/fayeznazzal/TestGPT-logo.svg\" width=\"16px\" height=\"16px\" /\u003e Locally / Config-based\n\nFor extra flexibility, having `testgpt.config.yaml` at your project's root allows for running shorter commands, quicker, and more friendly for repetitive usage.\n\nAn example of a `testgpt.config.yaml` file:\n\n```yaml\n.tsx:\n  techs:\n    - jest\n    - react-testing-library\n  instructions: |-\n    Wrap test groups in 'describe' blocks\n  examples:\n    - fileName: file1.tsx\n      code: \u003ccode for file1.tsx\u003e\n      tests: \u003ctests for file1.tsx\u003e\n    - fileName: file2.tsx\n      code: \u003ccode for file2.tsx\u003e\n      tests: \u003ctests for file2.tsx\u003e\n```\n\n\u003e More and longer examples enhance the test quality. This will be more possible with high-context length models like gpt-3.5-turbo-16k or gpt-4-32k.\n\n## \u003cimg style=\"padding-right: 4px;\" src=\"https://storage.googleapis.com/fayeznazzal/TestGPT-logo.svg\" width=\"24px\" height=\"24px\" /\u003e License\n\nThis software is licensed under the MIT License, which permits you to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, subject to the following conditions:\n\n- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.\n- The software is provided \"as is\", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement.\n- In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.\n\nPlease feel free to use this software in any way you see fit, and contributions are always welcome :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffayez-nazzal%2Ftestgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffayez-nazzal%2Ftestgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffayez-nazzal%2Ftestgpt/lists"}