Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

assert that the returned sandbox info objects are sorted by start time in the js-sdk Sanbox.list test

0div4c2f97afbbeb
diff --git a/packages/js-sdk/tests/api/list.test.ts b/packages/js-sdk/tests/api/list.test.ts
index b121a88f1..c692f6a49 100644
--- a/packages/js-sdk/tests/api/list.test.ts
+++ b/packages/js-sdk/tests/api/list.test.ts
@@ -1,10 +1,22 @@
import { assert } from 'vitest'
import { Sandbox } from '../../src'
-import { sandboxTest, isDebug } from '../setup.js'
+import { isDebug, sandboxTest } from '../setup.js'
sandboxTest.skipIf(isDebug)('list sandboxes', async ({ sandbox }) => {
const sandboxes = await Sandbox.list()
assert.isAtLeast(sandboxes.length, 1)
- assert.include(sandboxes.map((s) => s.sandboxId), sandbox.sandboxId)
+ assert.include(
+ sandboxes.map((s) => s.sandboxId),
+ sandbox.sandboxId
+ )
+
+ // Check that sandboxes are sorted by startedAt in descending order (newest first)
+ for (let i = 0; i < sandboxes.length - 1; i++) {
+ assert.isAtLeast(
+ new Date(sandboxes[i].startedAt).getTime(),
+ new Date(sandboxes[i + 1].startedAt).getTime(),
+ 'Sandboxes should be sorted by startedAt in descending order'
+ )
+ }
})