Package Exports
- axium-cli
- axium-cli/dist/cli.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (axium-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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