@@ -11,7 +11,7 @@ import {
11
11
ExportsManager ,
12
12
validateExportName ,
13
13
} from "../../../src/common/exportsManager.js" ;
14
-
14
+ import type { AvailableExport } from "../../../src/common/exportsManager.js" ;
15
15
import { config } from "../../../src/common/config.js" ;
16
16
import { ROOT_DIR } from "../../accuracy/sdk/constants.js" ;
17
17
import { timeout } from "../../integration/helpers.js" ;
@@ -124,6 +124,15 @@ function timeoutPromise(timeoutMS: number, context: string): Promise<never> {
124
124
} ) ;
125
125
}
126
126
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
+
127
136
async function getExportAvailableNotifier (
128
137
expectedExportURI : string ,
129
138
manager : ExportsManager ,
@@ -318,7 +327,8 @@ describe("ExportsManager unit test", () => {
318
327
await cursorCloseNotification ;
319
328
320
329
// 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 ) ;
322
332
expect ( availableExports ) . toHaveLength ( 1 ) ;
323
333
expect ( availableExports ) . toContainEqual (
324
334
expect . objectContaining ( {
@@ -352,7 +362,7 @@ describe("ExportsManager unit test", () => {
352
362
353
363
const expectedExportName = exportName . endsWith ( ".json" ) ? exportName : `${ exportName } .json` ;
354
364
// Updates available export
355
- const availableExports = manager . availableExports ;
365
+ const availableExports = await waitUntilThereIsAnExportAvailable ( manager ) ;
356
366
expect ( availableExports ) . toHaveLength ( 1 ) ;
357
367
expect ( availableExports ) . toContainEqual (
358
368
expect . objectContaining ( {
@@ -387,7 +397,7 @@ describe("ExportsManager unit test", () => {
387
397
388
398
const expectedExportName = exportName . endsWith ( ".json" ) ? exportName : `${ exportName } .json` ;
389
399
// Updates available export
390
- const availableExports = manager . availableExports ;
400
+ const availableExports = await waitUntilThereIsAnExportAvailable ( manager ) ;
391
401
expect ( availableExports ) . toHaveLength ( 1 ) ;
392
402
expect ( availableExports ) . toContainEqual (
393
403
expect . objectContaining ( {
0 commit comments