@dheerajsingh5832/smart-testgen
v1.0.0
Published
Generate high-quality LLM prompts for test generation without calling any LLM API
Downloads
53
Maintainers
Readme
smart-testgen
Generate high-quality LLM prompts for test generation without calling any LLM API
Perfect for use with GitHub Copilot, Cursor, ChatGPT, Claude, or any AI assistant.
Features
- ✅ No LLM API calls - generates prompts only, you control the AI
- ✅ IDE-agnostic - works with any AI tool (Copilot, Cursor, ChatGPT, Claude)
- ✅ Multiple frameworks - Jest, Vitest, Mocha
- ✅ Multiple test types - Unit, Integration, E2E
- ✅ TypeScript support - fully typed with strict mode
- ✅ CLI included - easy to use from terminal
- ✅ No vendor lock-in - use any LLM you prefer
Installation
npm install -g smart-testgenQuick Start
1. Generate a prompt
smart-testgen generate --file src/calculator.ts --framework jest --type unit --ide2. Copy the output
The tool outputs a formatted prompt:
========================================
PASTE THIS INTO COPILOT OR CURSOR
========================================
You are a senior QA automation engineer.
Generate jest unit tests for the following code.
Rules:
- Cover happy path
- Cover edge cases
- Cover invalid inputs
...
========================================3. Paste into your AI tool
- GitHub Copilot Chat (
Cmd+Shift+Iin VS Code) - Cursor
- ChatGPT
- Claude
- Any AI assistant
4. Get complete test code
The AI generates comprehensive tests based on the prompt.
Usage
Command Syntax
smart-testgen generate [options]Options
| Option | Description | Required | Default |
|--------|-------------|----------|---------|
| --file <path> | Path to source file | Yes | - |
| --framework <name> | Test framework (jest/vitest/mocha) | Yes | - |
| --type <type> | Test type (unit/integration/e2e) | No | unit |
| --ide | Generate prompt for IDE LLM | No | true |
| --output <path> | Save prompt to file | No | - |
Examples
Jest Unit Tests
smart-testgen generate --file src/calculator.ts --framework jest --type unit --ideVitest Integration Tests
smart-testgen generate --file src/api.ts --framework vitest --type integration --ideMocha E2E Tests
smart-testgen generate --file src/app.ts --framework mocha --type e2e --ideSave Prompt to File
smart-testgen generate --file src/utils.ts --framework jest --type unit --ide --output prompt.txtSupported Frameworks
| Framework | Command | Description |
|-----------|---------|-------------|
| Jest | --framework jest | Most popular for React/Node.js |
| Vitest | --framework vitest | Fast, Vite-native testing |
| Mocha | --framework mocha | Flexible testing framework |
Supported Test Types
| Type | Command | Description |
|------|---------|-------------|
| Unit | --type unit | Test individual functions/components |
| Integration | --type integration | Test module interactions |
| E2E | --type e2e | Test complete user flows |
Programmatic Usage
import { TestGenerator } from 'smart-testgen';
const generator = new TestGenerator();
const result = await generator.generate({
filePath: 'src/utils.ts',
framework: 'jest',
testType: 'unit',
mode: 'ide'
});
console.log(result.prompt); // Copy this to your AI toolWhy smart-testgen?
✅ No API Costs
Never calls OpenAI, Anthropic, or any LLM API. Use your existing Copilot/Cursor subscription or free AI tools.
✅ Maximum Control
- You decide which AI to use
- You review prompts before sending
- You control the output
✅ Privacy First
- No code sent to external APIs by this tool
- You control what gets sent to AI
- Works completely offline (until you paste to AI)
✅ Framework Agnostic
- Works with any AI tool
- Not locked into one vendor
- Future-proof
Workflow
┌─────────────────┐
│ Your Code │
└────────┬────────┘
│
▼
┌─────────────────┐
│ smart-testgen │ ← Generates prompt
└────────┬────────┘
│
▼
┌─────────────────┐
│ Copy & Paste │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Your AI Tool │ ← Copilot/Cursor/ChatGPT/Claude
└────────┬────────┘
│
▼
┌─────────────────┐
│ Test Code │ ← Ready to use
└─────────────────┘Help Commands
# Show version
smart-testgen --version
# Show help
smart-testgen --help
# Show framework information
smart-testgen help-frameworksExamples
Example 1: React Component
smart-testgen generate --file src/components/Button.jsx --framework jest --type unit --ideExample 2: API Service
smart-testgen generate --file src/services/userService.ts --framework vitest --type integration --ideExample 3: Utility Functions
smart-testgen generate --file src/utils/validators.ts --framework mocha --type unit --ideTips
💡 Start simple - Try with a small file first to understand the prompt format
💡 Review prompts - Check the generated prompt before pasting to AI
💡 Adjust as needed - Modify prompts to match your project conventions
💡 Use --output - Save prompts for reuse or documentation
💡 Try different types - Experiment with unit, integration, and e2e tests
Requirements
- Node.js 16.0.0 or higher
- Any AI tool (Copilot, Cursor, ChatGPT, Claude, etc.)
Contributing
Contributions welcome! Please see the GitHub repository.
License
MIT © [Your Name]
Links
Made with ❤️ for developers who love AI-assisted testing
