Files
insights-js/packages/ai/tests/test-utils.ts
Radu RaiceaandGitHub 61b6073bdf fix(llma): various bug fixes related to tools for streaming providers (#2230)
* fix(llma): missing tool call in Anthropic streaming output

* fix(llma): missing tool call in Gemini streaming output

* fix(llma): missing tool call in OpenAI Completions API streaming output

* fix(llma): missing $ai_tools for Vercel

* fix(llma): missing tool call in Vercel streaming output

* chore(llma): run linter

* chore(llma): apply feedback

* chore(llma): run linter
2025-08-20 16:57:01 -04:00

26 lines
696 B
TypeScript

/**
* Test utilities for async operations
*/
/**
* Waits for async operations to complete
* Uses process.nextTick to ensure all microtasks are processed
*/
export async function waitForAsyncOperations(): Promise<void> {
// Use process.nextTick to wait for all microtasks
await new Promise(process.nextTick)
// If fake timers are enabled, run them and flush again
if (jest.isMockFunction(setTimeout)) {
jest.runAllTimers()
await new Promise(process.nextTick)
}
}
/**
* Alternative helper for tests that don't use fake timers
* but still need to wait for async operations
*/
export async function flushPromises(): Promise<void> {
await new Promise(process.nextTick)
}