thrilled-be-testing
Version:
Testing utilities and helpers package with Jest, Supertest, and database testing support for Express applications
114 lines • 3.42 kB
TypeScript
/**
* Simple Testing Utilities
* Basic testing utilities that work without complex dependencies
*/
/**
* Simple Mock Data Factory
*/
export declare class SimpleMockFactory {
private static sequence;
/**
* Get next sequence number for a given key
*/
static getSequence(key: string): number;
/**
* Reset sequences
*/
static reset(): void;
/**
* Generate random string
*/
static randomString(length?: number, prefix?: string): string;
/**
* Generate random number within range
*/
static randomNumber(min?: number, max?: number): number;
/**
* Generate random date within range
*/
static randomDate(startDate?: Date, endDate?: Date): Date;
/**
* Create mock user
*/
static createUser(overrides?: Record<string, unknown>): Record<string, unknown>;
/**
* Create mock API response
*/
static createApiResponse(data?: unknown, overrides?: Record<string, unknown>): Record<string, unknown>;
/**
* Create mock error response
*/
static createErrorResponse(error?: Record<string, unknown>, overrides?: Record<string, unknown>): Record<string, unknown>;
}
/**
* Simple Test Helpers
*/
export declare class SimpleTestHelpers {
/**
* Create a basic Jest setup
* Note: This should be called at the top level of a test file, not inside a test case
*/
static setupTest(options?: {
beforeAll?: () => Promise<void> | void;
afterAll?: () => Promise<void> | void;
beforeEach?: () => Promise<void> | void;
afterEach?: () => Promise<void> | void;
}): void;
/**
* Create test setup configuration (for testing the setupTest method)
*/
static createTestSetup(options?: {
beforeAll?: () => Promise<void> | void;
afterAll?: () => Promise<void> | void;
beforeEach?: () => Promise<void> | void;
afterEach?: () => Promise<void> | void;
}): {
beforeAll?: () => Promise<void> | void;
afterAll?: () => Promise<void> | void;
beforeEach?: () => Promise<void> | void;
afterEach?: () => Promise<void> | void;
};
/**
* Create mock database connection
*/
static createMockDb(): Record<string, unknown>;
/**
* Create mock Express request
*/
static createMockRequest(overrides?: Record<string, unknown>): Record<string, unknown>;
/**
* Create mock Express response
*/
static createMockResponse(): Record<string, unknown>;
/**
* Wait for a specified amount of time
*/
static wait(ms: number): Promise<void>;
/**
* Assert that a value is truthy
*/
static assertTruthy(value: unknown, message?: string): void;
/**
* Assert that values are equal
*/
static assertEqual<T>(actual: T, expected: T, message?: string): void;
}
/**
* Test utilities for environment setup
*/
export declare class TestEnvironment {
private static envBackup;
/**
* Set environment variables for testing
*/
static setEnv(env: Record<string, string>): void;
/**
* Restore original environment variables
*/
static restoreEnv(): void;
/**
* Create isolated test environment
*/
static isolatedTest(testFn: () => Promise<void> | void, env?: Record<string, string>): () => Promise<void>;
}
//# sourceMappingURL=simple-testing.d.ts.map