superaugment
Version:
Enterprise-grade MCP server with world-class C++ analysis, robust error handling, and production-ready architecture for VS Code Augment
203 lines • 5.75 kB
TypeScript
/**
* SuperAugment Test Helpers
*
* Provides comprehensive testing utilities for unit tests, integration tests,
* and end-to-end testing scenarios. Designed to be reusable and maintainable.
*/
import { jest } from '@jest/globals';
import { ConfigManager } from '../config/ConfigManager.js';
import { SchemaConverter } from '../utils/SchemaConverter.js';
import { ToolManager } from '../tools/ToolManager.js';
import { z } from 'zod';
/**
* Test configuration options
*/
export interface TestConfig {
enableLogging: boolean;
mockFileSystem: boolean;
mockNetwork: boolean;
tempDirectory: string;
}
/**
* Mock file system structure
*/
export interface MockFileStructure {
[]: string | MockFileStructure;
}
/**
* Test assertion helpers
*/
export declare class TestAssertions {
/**
* Assert that an error is of a specific type
*/
static assertErrorType<T extends Error>(error: unknown, errorClass: new (...args: any[]) => T): asserts error is T;
/**
* Assert that a promise rejects with a specific error type
*/
static assertRejects<T extends Error>(promise: Promise<any>, errorClass: new (...args: any[]) => T): Promise<T>;
/**
* Assert that an object has specific properties
*/
static assertHasProperties<T extends object>(obj: T, properties: (keyof T)[]): void;
/**
* Assert that a schema conversion is valid
*/
static assertValidJsonSchema(schema: any): void;
}
/**
* Mock factory for creating test doubles
*/
export declare class MockFactory {
/**
* Create a mock ConfigManager
*/
static createMockConfigManager(overrides?: Partial<any>): jest.Mocked<ConfigManager>;
/**
* Create a mock FileSystemManager
*/
static createMockFileSystemManager(mockFiles?: MockFileStructure): any;
/**
* Get mock file content from structure
*/
private static getMockFileContent;
/**
* Create a mock SchemaConverter
*/
static createMockSchemaConverter(): jest.Mocked<SchemaConverter>;
/**
* Create a mock ErrorHandler
*/
static createMockErrorHandler(): any;
}
/**
* Test data generators
*/
export declare class TestDataGenerator {
/**
* Generate a sample Zod schema for testing
*/
static createSampleZodSchema(): z.ZodObject<{
name: z.ZodString;
age: z.ZodNumber;
email: z.ZodOptional<z.ZodString>;
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
isActive: z.ZodDefault<z.ZodBoolean>;
category: z.ZodEnum<["A", "B", "C"]>;
}, "strip", z.ZodTypeAny, {
name: string;
category: "C" | "A" | "B";
age: number;
tags: string[];
isActive: boolean;
email?: string | undefined;
}, {
name: string;
category: "C" | "A" | "B";
age: number;
email?: string | undefined;
tags?: string[] | undefined;
isActive?: boolean | undefined;
}>;
/**
* Generate sample C++ code for testing
*/
static createSampleCppCode(): string;
/**
* Generate sample TypeScript code for testing
*/
static createSampleTypeScriptCode(): string;
/**
* Generate sample configuration for testing
*/
static createSampleConfig(): {
tools: {
enabled: boolean;
timeout: number;
maxConcurrency: number;
analysis: {
enableCpp: boolean;
enableTypeScript: boolean;
enablePython: boolean;
};
};
logging: {
level: string;
enableConsole: boolean;
enableFile: boolean;
maxFileSize: string;
};
cache: {
enabled: boolean;
maxMemoryUsage: string;
maxEntries: number;
ttl: string;
};
};
}
/**
* Test environment setup and teardown
*/
export declare class TestEnvironment {
private static originalEnv;
/**
* Setup test environment
*/
static setup(config?: Partial<TestConfig>): void;
/**
* Teardown test environment
*/
static teardown(): void;
/**
* Create a temporary test directory
*/
static createTempDir(): Promise<string>;
/**
* Clean up temporary test directory
*/
static cleanupTempDir(_path: string): Promise<void>;
}
/**
* Performance testing utilities
*/
export declare class PerformanceTestUtils {
/**
* Measure execution time of a function
*/
static measureExecutionTime<T>(fn: () => Promise<T> | T): Promise<{
result: T;
duration: number;
}>;
/**
* Assert that a function executes within a time limit
*/
static assertExecutionTime<T>(fn: () => Promise<T> | T, maxDuration: number): Promise<T>;
/**
* Run a function multiple times and get statistics
*/
static benchmarkFunction<T>(fn: () => Promise<T> | T, iterations?: number): Promise<{
results: T[];
durations: number[];
averageDuration: number;
minDuration: number;
maxDuration: number;
}>;
}
/**
* Integration test helpers
*/
export declare class IntegrationTestHelpers {
/**
* Create a full ToolManager instance for integration testing
*/
static createTestToolManager(configOverrides?: any): Promise<ToolManager>;
/**
* Test MCP protocol compatibility
*/
static testMcpCompatibility(toolManager: ToolManager): Promise<void>;
/**
* Test tool execution with sample data
*/
static testToolExecution(toolManager: ToolManager, toolName: string, args: any): Promise<any>;
}
//# sourceMappingURL=TestHelpers.d.ts.map