syntropylog
Version:
An instance manager with observability for Node.js applications
57 lines (56 loc) • 1.68 kB
TypeScript
/**
* Test helper for SyntropyLog applications
*
* This helper provides a simple way to set up tests with SyntropyLog mocks
* without dealing with initialization/shutdown issues.
*/
export interface TestHelper {
mockSyntropyLog: any;
beforeEach: () => void;
afterEach: () => void;
}
/**
* Create a test helper for SyntropyLog testing
*
* @param spyFn - Optional spy function for framework compatibility (vi.fn, jest.fn, etc.)
*
* @example
* ```typescript
* // For Vitest
* const testHelper = createTestHelper(vi.fn);
*
* // For Jest
* const testHelper = createTestHelper(jest.fn);
*
* // For Jasmine
* const testHelper = createTestHelper(jasmine.createSpy);
*
* // Without spy (basic functionality only)
* const testHelper = createTestHelper();
*
* describe('MyService', () => {
* beforeEach(() => testHelper.beforeEach());
* afterEach(() => testHelper.afterEach());
*
* it('should work', () => {
* const service = new MyService(testHelper.mockSyntropyLog);
* // ... test logic
* });
* });
* ```
*/
export declare function createTestHelper(spyFn?: (implementation?: any) => any): TestHelper;
/**
* Create a service with SyntropyLog mock for testing
*
* @param ServiceClass - The service class to instantiate
* @param mockSyntropyLog - The mock SyntropyLog instance
* @returns Instance of the service with mock injected
*
* @example
* ```typescript
* const mockSyntropyLog = createSyntropyLogMock();
* const userService = createServiceWithMock(UserService, mockSyntropyLog);
* ```
*/
export declare function createServiceWithMock<T>(ServiceClass: new (syntropyLog?: any) => T, mockSyntropyLog: any): T;