XibeCode

AI Test Generation

Automatically generate comprehensive test suites for your code using AI-powered analysis. Supports Vitest, Jest, Mocha, pytest, and Go test.

Automatically generate comprehensive test suites for your code using AI-powered analysis.

Quick Start

Via CLI (in chat mode)

xibecode chat
> generate tests for src/utils/helpers.ts

Via Autonomous Run

xibecode run "Generate comprehensive tests for src/utils/helpers.ts"

Supported Frameworks

FrameworkLanguageFeatures
VitestJavaScript/TypeScriptdescribe/it blocks, vi.mock() setup, expect assertions
JestJavaScript/TypeScriptdescribe/it blocks, jest.mock() setup, expect assertions
MochaJavaScript/TypeScriptdescribe/it blocks, Sinon mocks, Chai assertions
pytestPythonclass TestX format, Mock/patch setup, assert statements
Go testGofunc TestX format, testify/mock, assert package
Auto-detectAnyReads package.json, checks dependencies, falls back to Vitest

Features

  • Code Analysis — Understands functions, classes, types, imports, and exports. Detects complexity and dependencies.
  • Edge Case Generation — Automatically generates tests for null values, empty strings, boundary conditions, and error cases.
  • Type Checking — Creates assertions for return types, ensuring functions return expected data types.
  • Mock Setup — Automatically configures mocks for dependencies and external modules.

Tool API

generate_tests

Analyze a source file and generate comprehensive test cases.

ParameterTypeDescription
file_pathstringPath to source file (required)
frameworkstringvitest, jest, mocha, pytest, go (auto-detected)
output_dirstringCustom output directory for tests
include_edge_casesbooleanInclude edge case tests (default: true)
include_mocksbooleanInclude mock setup code (default: true)
max_tests_per_functionnumberMaximum tests per function (default: 5)
write_filebooleanWrite to file (default: false)

analyze_code_for_tests

Analyze a source file to understand its structure before generating tests.

ParameterTypeDescription
file_pathstringPath to source file (required)

Example Output

Given a file with a calculateTotal function:

import { describe, it, expect, vi } from "vitest";
import { calculateTotal } from "../utils/helpers";

beforeEach(() => {
  vi.clearAllMocks();
});

describe("calculateTotal", () => {
  it("should execute calculateTotal successfully", () => {
    expect(calculateTotal([])).toBeDefined();
  });

  it("should return correct type from calculateTotal", () => {
    expect(typeof calculateTotal([])).toBe("number");
  });

  it("should handle empty array", () => {
    expect(calculateTotal([])).toBe(0);
  });

  it("should handle single element", () => {
    expect(calculateTotal([10])).toBe(10);
  });

  it("should handle errors in calculateTotal", () => {
    expect(() => calculateTotal(undefined)).toThrow();
  });
});

Generated Test Types

TypeDescriptionExample
unitBasic functionality testsFunction returns expected value
edgeEdge case and boundary testsEmpty string, null, MAX_INT
boundaryBoundary condition testsArray length 0, 1, MAX
errorError handling testsInvalid input throws error

Best Practices

  • Review generated tests — AI-generated tests are a starting point, not the final product
  • Add domain-specific assertions — The generator may miss business logic requirements
  • Use write_file: false first — Preview tests before writing to disk
  • Run tests after generation — Verify they pass and cover expected behavior
  • Customize edge cases — Add project-specific edge cases as needed

Programmatic Usage

Use test generation from the xibecode-core library:

import { CodingToolExecutor } from 'xibecode-core';

const executor = new CodingToolExecutor(process.cwd());
const result = await executor.executeTool('generate_tests', {
  file_path: 'src/utils/helpers.ts',
  framework: 'vitest',
});
Ctrl+I
Assistant

How can I help?

Ask me about configuration, installation, or specific features.