@@ -11,7 +11,7 @@ import {
1111 ExportsManager ,
1212 validateExportName ,
1313} from "../../../src/common/exportsManager.js" ;
14-
14+ import type { AvailableExport } from "../../../src/common/exportsManager.js" ;
1515import { config } from "../../../src/common/config.js" ;
1616import { ROOT_DIR } from "../../accuracy/sdk/constants.js" ;
1717import { timeout } from "../../integration/helpers.js" ;
@@ -124,6 +124,15 @@ function timeoutPromise(timeoutMS: number, context: string): Promise<never> {
124124 } ) ;
125125}
126126
127+ async function waitUntilThereIsAnExportAvailable ( manager : ExportsManager ) : Promise < AvailableExport [ ] > {
128+ return await vi . waitFor ( ( ) => {
129+ const exports = manager . availableExports ;
130+ expect ( exports . length ) . toBeGreaterThan ( 0 ) ;
131+
132+ return exports ;
133+ } ) ;
134+ }
135+
127136async function getExportAvailableNotifier (
128137 expectedExportURI : string ,
129138 manager : ExportsManager ,
@@ -318,7 +327,8 @@ describe("ExportsManager unit test", () => {
318327 await cursorCloseNotification ;
319328
320329 // Updates available export
321- const availableExports = manager . availableExports ;
330+ // this is async code so we should wait and retry
331+ const availableExports = await waitUntilThereIsAnExportAvailable ( manager ) ;
322332 expect ( availableExports ) . toHaveLength ( 1 ) ;
323333 expect ( availableExports ) . toContainEqual (
324334 expect . objectContaining ( {
@@ -352,7 +362,7 @@ describe("ExportsManager unit test", () => {
352362
353363 const expectedExportName = exportName . endsWith ( ".json" ) ? exportName : `${ exportName } .json` ;
354364 // Updates available export
355- const availableExports = manager . availableExports ;
365+ const availableExports = await waitUntilThereIsAnExportAvailable ( manager ) ;
356366 expect ( availableExports ) . toHaveLength ( 1 ) ;
357367 expect ( availableExports ) . toContainEqual (
358368 expect . objectContaining ( {
@@ -387,7 +397,7 @@ describe("ExportsManager unit test", () => {
387397
388398 const expectedExportName = exportName . endsWith ( ".json" ) ? exportName : `${ exportName } .json` ;
389399 // Updates available export
390- const availableExports = manager . availableExports ;
400+ const availableExports = await waitUntilThereIsAnExportAvailable ( manager ) ;
391401 expect ( availableExports ) . toHaveLength ( 1 ) ;
392402 expect ( availableExports ) . toContainEqual (
393403 expect . objectContaining ( {
0 commit comments