axium-cli
v1.0.6
Published
AI-powered test generation for Next.js & NestJS applications with auto-fix
Maintainers
Readme
Axium CLI v1.0.6
🚀 AI-Powered Test Generation with Auto-Fix for Next.js & NestJS
✨ New Feature: Auto-Fix 🔧
Axium can now automatically fix failing tests until they pass!
axium auto-fix src/users/users.service.tsThe CLI will:
- ✅ Generate the test
- ✅ Run it
- ✅ Detect errors
- ✅ Fix them with AI
- ✅ Retry until all tests pass
📦 Installation
npm install -g axium-cli🚀 Quick Start
# Initialize
axium init
# Generate and auto-fix a test
axium auto-fix src/users/users.service.ts
# Regular generation
axium generate src/users/users.service.ts
# Scan directory
axium scan src/🎯 Commands
axium auto-fix <file> 🆕
Automatically generate and fix tests until they pass!
# Basic usage
axium auto-fix src/users/users.service.ts
# With options
axium auto-fix src/users/users.service.ts \
--max-retries 5 \
--verbose \
--test-framework jest
# Options:
--max-retries <number> Maximum fix attempts (default: 5)
--timeout <ms> Test execution timeout (default: 60000)
--test-framework <name> jest or vitest
--dry-run Preview without saving
--no-save-report Don't save the report
--verbose Show detailed outputWhat it does:
Step 1: Generate test
↓
Step 2: Run test → ✅ Pass? → Done!
↓ ❌ Fail?
Step 3: Analyze errors
↓
Step 4: Fix with AI
↓
Step 5: Save fixed test
↓
Back to Step 2 (max 5 iterations)Example output:
╔════════════════════════════════════════════════════════════╗
║ 🎯 AUTO-FIX REPORT ║
╠════════════════════════════════════════════════════════════╣
║ 📁 Source File: src/users/users.service.ts ║
║ 🧪 Test File: src/users/users.service.spec.ts ║
║ ║
║ Status: ✅ SUCCESS ║
║ ║
║ 📊 Statistics: ║
║ • Attempts: 3 ║
║ • Errors Solved: 4 ║
║ • Errors Remaining: 0 ║
║ • Total Duration: 12500ms ║
║ ║
║ 🔄 Attempts: ║
║ ❌ Iteration 1: 0/3 passed ║
║ ❌ Iteration 2: 1/3 passed ║
║ ✅ Iteration 3: 3/3 passed ║
╚════════════════════════════════════════════════════════════╝
🎉 All tests are now passing!axium generate <file>
Generate tests for a specific file.
axium generate src/users/users.service.ts
axium generate src/users/users.service.ts --test-framework vitest
axium generate src/users/users.controller.ts --type e2eaxium scan <directory>
Scan and generate tests for all files.
axium scan src/
axium scan src/ --test-framework vitest --parallelaxium analyze <directory>
Analyze test coverage.
axium analyze src/ --report --suggestaxium watch [directory]
Watch and auto-generate on changes.
axium watch src/⚙️ Configuration
axium.config.js:
module.exports = {
model: {
provider: 'ollama',
name: 'codellama:13b',
baseUrl: 'http://localhost:11434',
},
framework: {
type: 'nestjs',
},
test: {
framework: 'jest',
parallel: true,
maxConcurrency: 5,
},
};🎯 Auto-Fix Features
Smart Error Detection
- ✅ Import errors
- ✅ Syntax errors
- ✅ Mock errors
- ✅ Assertion failures
- ✅ Runtime errors
- ✅ Timeout issues
Intelligent Fixing
- 🧠 AI analyzes the error context
- 🔧 Generates targeted fixes
- 📊 Prioritizes critical errors
- 🔄 Iterates until success
- 💾 Saves detailed reports
Error Examples Fixed Automatically
Import Error:
❌ Cannot find module '@nestjs/testing'
✅ Fixed: Added missing importMock Error:
❌ TypeError: mockRepository.find is not a function
✅ Fixed: Added jest.fn() to mockAssertion Error:
❌ Expected: [Array], Received: undefined
✅ Fixed: Added proper mock return value📊 Comparison
| Feature | generate | auto-fix 🆕 |
|---------|-----------|--------------|
| Generate test | ✅ | ✅ |
| Run test | ❌ | ✅ |
| Detect errors | ❌ | ✅ |
| Fix automatically | ❌ | ✅ |
| Retry loop | ❌ | ✅ |
| Detailed report | ❌ | ✅ |
🎬 Workflow Examples
Example 1: NestJS Service
# Create a service
cat > src/users/users.service.ts << 'EOF'
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from './user.entity';
@Injectable()
export class UsersService {
constructor(
@InjectRepository(User)
private userRepository: Repository<User>,
) {}
async findAll(): Promise<User[]> {
return this.userRepository.find();
}
}
EOF
# Auto-fix it!
axium auto-fix src/users/users.service.ts
# Output:
# 🚀 Starting auto-fix for: users.service.ts
# 🔍 Analyzing source code...
# 🤖 Generating initial test...
# ✅ Test file created: src/users/users.service.spec.ts
#
# 🔄 Attempt 1/5
# 🧪 Running test...
# ❌ Tests failed: 1/3
# 📊 Analyzing errors...
# 🔧 Generating fix with AI...
# 💾 Fixed test saved
#
# 🔄 Attempt 2/5
# 🧪 Running test...
# ✅ All tests passed! (3/3)
#
# 🎉 All tests are now passing!Example 2: Next.js API Route
# Auto-fix Next.js route
axium auto-fix src/app/api/users/route.ts --test-framework vitest
# The CLI will:
# 1. Detect it's Next.js
# 2. Generate route.test.ts (not .spec.ts)
# 3. Run vitest
# 4. Fix errors
# 5. Until all pass🐛 Troubleshooting
"jest is not installed"
npm install --save-dev jest @types/jest ts-jest"Test execution timed out"
axium auto-fix file.ts --timeout 120000 # 2 minutes"Max retries reached"
# Increase retries
axium auto-fix file.ts --max-retries 10
# Or check the report
cat .axium-reports/autofix-*.json📈 Roadmap
v1.1.0 (Current)
- ✅ Auto-fix for single files
- ✅ Error detection and analysis
- ✅ AI-powered fixes
- ✅ Detailed reports
v1.2.0 (Next)
- 🔄
axium auto-fix-scan- Auto-fix entire directories - 📊 Coverage-driven test generation
- 🎨 Interactive mode
- 🔔 Watch mode with auto-fix
v1.3.0 (Future)
- 🧬 Mutation testing
- 🤖 Smart test suggestions
- 📈 Quality metrics
- 🔌 Plugin system
🤝 Contributing
Contributions welcome! Please read CONTRIBUTING.md.
📄 License
MIT
Made with ❤️ by Armel Dakayao
NPM# axium-cli
