Browse Source

test(e2b): poll sandbox list convergence

Tianyi Cui 2 months ago
parent
commit
258bd4456b
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/e2b/e2b/tests/composition.e2e.ts

+ 4 - 1
packages/e2b/e2b/tests/composition.e2e.ts

@@ -178,6 +178,9 @@ describe.skipIf(!process.env.E2B_API_KEY)('E2B live Loader composition', () => {
     const apiKey = process.env.E2B_API_KEY
     if (apiKey === undefined) throw new Error('E2B_API_KEY disappeared during the live composition test')
     await expect(Sandbox.getInfo(String(output.sandboxId), { apiKey })).rejects.toBeInstanceOf(SandboxNotFoundError)
-    await expect(Sandbox.list({ apiKey }).nextItems()).resolves.toEqual([])
+    await expect.poll(async () => {
+      const sandboxes = await Sandbox.list({ apiKey }).nextItems()
+      return sandboxes.some(sandbox => sandbox.sandboxId === output.sandboxId)
+    }, { interval: 250, timeout: 5_000 }).toBe(false)
   }, 195_000)
 })