JSPM

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

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

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

🚀 AI-Powered Test Generation for Next.js & NestJS

Generate comprehensive tests automatically using AI (Gemini, Ollama, or Mistral).

📦 Installation

npm install -g axium-cli

🚀 Quick Start

1. Initialize Configuration

axium init

This creates an axium.config.ts file in your project.

2. Configure AI Provider

Option A: Ollama (Local, Free)

# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh

# Pull a model
ollama pull codellama:13b

# Start Ollama
ollama serve

Option B: Google Gemini

# Set API key
export GOOGLE_API_KEY=your_api_key_here

Option C: Mistral AI

# Set API key
export MISTRAL_API_KEY=your_api_key_here

3. Generate Tests

# Generate a test file
axium generate src/users/users.service.ts

# Use Vitest instead of Jest
axium generate src/users/users.service.ts --test-framework vitest

# Scan entire directory
axium scan src/

# Watch mode
axium watch src/

📝 Commands

axium generate <file>

Generate tests for a specific file.

# Unit test (Jest by default)
axium generate src/users/users.service.ts

# Unit test with Vitest
axium generate src/users/users.service.ts --test-framework vitest

# E2E test
axium generate src/users/users.controller.ts --type e2e

# With comprehensive mocks
axium generate src/users/users.service.ts --with-mocks

# Dry run (preview without saving)
axium generate src/file.ts --dry-run

axium scan <directory>

Scan a directory and generate tests for all files.

# Scan with Jest (default)
axium scan src/

# Scan with Vitest
axium scan src/ --test-framework vitest

# Parallel processing
axium scan src/ --parallel --max-concurrency 5

# Exclude patterns
axium scan src/ --exclude "**/*.dto.ts,**/*.entity.ts"

axium analyze <directory>

Analyze test coverage.

# Basic analysis
axium analyze src/

# With report
axium analyze src/ --report

# With suggestions
axium analyze src/ --suggest

axium watch [directory]

Watch files and auto-generate tests.

# Watch with Jest
axium watch src/

# Watch with Vitest
axium watch src/ --test-framework vitest

axium init

Initialize configuration file.

# TypeScript config (default)
axium init

# JavaScript config
axium init --format js

⚙️ Configuration

Edit axium.config.ts:

import { AxiumConfig } from 'axium-cli';

const config: AxiumConfig = {
  model: {
    provider: 'ollama', // 'gemini' | 'ollama' | 'mistral'
    name: 'codellama:13b',
    temperature: 0.7,
    maxTokens: 4096,
  },

  framework: {
    type: 'nestjs', // 'nestjs' | 'nextjs' | 'both'
  },

  test: {
    framework: 'jest', // 'jest' | 'vitest'
    testDirectory: '__tests__',
    coverageTarget: 80,
    mockStrategy: 'comprehensive',
    parallel: true,
    maxConcurrency: 5,
  },

  cache: {
    enabled: true,
    ttl: 3600,
    directory: '.axium-cache',
  },
};

export default config;

🎯 Supported Frameworks

NestJS

  • ✅ Controllers
  • ✅ Services
  • ✅ Guards
  • ✅ Interceptors
  • ✅ Pipes
  • ✅ Filters
  • ✅ Middleware

Next.js

  • ✅ API Routes
  • ✅ Server Components
  • ✅ Client Components
  • ✅ Middleware

🤖 AI Providers

Provider Type Cost Setup
Ollama Local Free ollama serve
Gemini Cloud Free tier API key
Mistral Cloud Paid API key

📊 Test Frameworks

Axium supports Jest (default) and Vitest:

# Use Jest (default)
axium generate file.ts

# Use Vitest
axium generate file.ts --test-framework vitest

# Set default in config
test: {
  framework: 'vitest',
}

🔧 Examples

Example 1: NestJS Service

// src/users/users.service.ts
@Injectable()
export class UsersService {
  constructor(
    @InjectRepository(User)
    private userRepository: Repository<User>,
  ) {}

  async findAll(): Promise<User[]> {
    return this.userRepository.find();
  }
}

Generate test:

axium generate src/users/users.service.ts

Generated test (Jest):

import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { UsersService } from './users.service';

describe('UsersService', () => {
  let service: UsersService;
  let repository: any;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        UsersService,
        {
          provide: getRepositoryToken(User),
          useValue: {
            find: jest.fn(),
          },
        },
      ],
    }).compile();

    service = module.get<UsersService>(UsersService);
    repository = module.get(getRepositoryToken(User));
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });

  describe('findAll', () => {
    it('should return an array of users', async () => {
      const users = [{ id: 1, name: 'Test' }];
      repository.find.mockResolvedValue(users);

      const result = await service.findAll();

      expect(result).toEqual(users);
      expect(repository.find).toHaveBeenCalled();
    });
  });
});

🐛 Troubleshooting

"Model not responding"

# For Ollama
ollama serve

# Check status
curl http://localhost:11434/api/tags

"Configuration not found"

# Initialize config
axium init

Clear cache

axium clean

📚 Documentation

🤝 Contributing

Contributions welcome! Please read CONTRIBUTING.md.

📄 License

MIT


Made with ❤️ by the Armel Dakayao