AI-powered test generation for Next.js & NestJS applications with auto-fix
npm install axium-cli๐ AI-Powered Test Generation with Auto-Fix for Next.js & NestJS
Axium can now automatically fix failing tests until they pass!
``bash`
axium auto-fix src/users/users.service.ts
The CLI will:
1. โ
Generate the test
2. โ
Run it
3. โ
Detect errors
4. โ
Fix them with AI
5. โ
Retry until all tests pass
---
`bash`
npm install -g axium-cli
`bashInitialize
axium init
---
๐ฏ Commands
$3
Automatically generate and fix tests until they pass!
`bash
Basic usage
axium auto-fix src/users/users.service.tsWith options
axium auto-fix src/users/users.service.ts \
--max-retries 5 \
--verbose \
--test-framework jestOptions:
--max-retries Maximum fix attempts (default: 5)
--timeout Test execution timeout (default: 60000)
--test-framework jest or vitest
--dry-run Preview without saving
--no-save-report Don't save the report
--verbose Show detailed output
`What 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!
`---
$3
Generate tests for a specific file.
`bash
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 e2e
`$3
Scan and generate tests for all files.
`bash
axium scan src/
axium scan src/ --test-framework vitest --parallel
`$3
Analyze test coverage.
`bash
axium analyze src/ --report --suggest
`$3
Watch and auto-generate on changes.
`bash
axium watch src/
`---
โ๏ธ Configuration
axium.config.js:`javascript
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
$3
- โ
Import errors
- โ
Syntax errors
- โ
Mock errors
- โ
Assertion failures
- โ
Runtime errors
- โ
Timeout issues
$3
- ๐ง AI analyzes the error context
- ๐ง Generates targeted fixes
- ๐ Prioritizes critical errors
- ๐ Iterates until success
- ๐พ Saves detailed reports
$3
Import Error:
`
โ Cannot find module '@nestjs/testing'
โ
Fixed: Added missing import
`Mock Error:
`
โ TypeError: mockRepository.find is not a function
โ
Fixed: Added jest.fn() to mock
`Assertion 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
$3
`bash
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,
) {}
async findAll(): Promise {
return this.userRepository.find();
}
}
EOF
Auto-fix it!
axium auto-fix src/users/users.service.tsOutput:
๐ 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!
`$3
`bash
Auto-fix Next.js route
axium auto-fix src/app/api/users/route.ts --test-framework vitestThe 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
$3
`bash
npm install --save-dev jest @types/jest ts-jest
`$3
`bash
axium auto-fix file.ts --timeout 120000 # 2 minutes
`$3
`bash
Increase retries
axium auto-fix file.ts --max-retries 10Or check the report
cat .axium-reports/autofix-*.json
`---
๐ Roadmap
$3
- โ
Auto-fix for single files
- โ
Error detection and analysis
- โ
AI-powered fixes
- โ
Detailed reports$3
- ๐ axium auto-fix-scan` - Auto-fix entire directories---
Contributions welcome! Please read CONTRIBUTING.md.
MIT
---
Made with โค๏ธ by Armel Dakayao
NPM# axium-cli