JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 44
  • Score
    100M100P100Q57682F
  • License MIT

AI-powered test generation for Next.js & NestJS applications with auto-fix

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.1.0

๐Ÿš€ 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.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

๐Ÿ“ฆ 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 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!

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 e2e

axium scan <directory>

Scan and generate tests for all files.

axium scan src/
axium scan src/ --test-framework vitest --parallel

axium analyze <directory>

Analyze test coverage.

axium analyze src/ --report --suggest

axium 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 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

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