UNPKG

torotask

Version:

Task queue processing in NodeJS based on BullMQ and Redis

29 lines 747 B
/** * Test utility functions */ /** * Waits for a condition to be met with timeout */ export async function waitFor(condition, timeoutMs = 5000, intervalMs = 100) { const startTime = Date.now(); while (Date.now() - startTime < timeoutMs) { if (await condition()) { return; } await new Promise((resolve) => setTimeout(resolve, intervalMs)); } throw new Error(`Condition not met within ${timeoutMs}ms`); } /** * Creates a delay promise */ export function delay(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } /** * Creates a jest mock function with proper typing */ export function createMockFunction() { return jest.fn(); } //# sourceMappingURL=test-utils.js.map