Skip to content

armgit / E2B

Public Imported from GitHub
0

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

[WIP] Fix tests

Tomas Valentac33dc5a7c6ef
diff --git a/packages/js-sdk/example.mts b/packages/js-sdk/example.mts
index 08982521c..b1e4b5013 100644
--- a/packages/js-sdk/example.mts
+++ b/packages/js-sdk/example.mts
@@ -1,14 +1,18 @@
import { Sandbox } from './dist'
-const sbx = await Sandbox.connect('3pcmtxu6u8it5f6flpkk', {
- // debug: true,
- // domain: 'e2b-staging.com',
- // timeoutMs: 5_000,
- // logger: console,
-})
+const start = Date.now()
+
+const sbx = await Sandbox.create()
+
+console.log('time', Date.now() - start)
+
+const list = Date.now()
const res = await sbx.files.list('/')
-// console.log(res)
+
+console.log(res)
+
+console.log('time', Date.now() - list)
// const l = await sbx.commands.list()
diff --git a/packages/js-sdk/tests/sandbox/files/remove.test.mts b/packages/js-sdk/tests/sandbox/files/remove.test.mts
index ddbc9e1f5..b3dcc02e7 100644
--- a/packages/js-sdk/tests/sandbox/files/remove.test.mts
+++ b/packages/js-sdk/tests/sandbox/files/remove.test.mts
@@ -1,6 +1,5 @@
-import { assert, expect } from 'vitest'
+import { assert } from 'vitest'
-import { NotFoundError } from '../../../src'
import { sandboxTest } from '../../setup.mjs'
sandboxTest('remove file', async ({ sandbox }) => {
@@ -16,5 +15,5 @@ sandboxTest('remove file', async ({ sandbox }) => {
sandboxTest('remove non-existing file', async ({ sandbox }) => {
const filename = 'non_existing_file.txt'
- await expect(sandbox.files.remove(filename)).rejects.toThrowError(NotFoundError)
+ await sandbox.files.remove(filename)
})
diff --git a/packages/js-sdk/tests/sandbox/files/write.test.mts b/packages/js-sdk/tests/sandbox/files/write.test.mts
index a944bc721..d8fe91b4e 100644
--- a/packages/js-sdk/tests/sandbox/files/write.test.mts
+++ b/packages/js-sdk/tests/sandbox/files/write.test.mts
@@ -1,4 +1,4 @@
-import { assert, expect } from 'vitest'
+import { assert } from 'vitest'
import { sandboxTest } from '../../setup.mjs'
@@ -26,7 +26,11 @@ sandboxTest('overwrite file', async ({ sandbox }) => {
sandboxTest('write to non-existing directory', async ({ sandbox }) => {
const filename = 'non_existing_dir/test_write.txt'
- const content = 'This should fail.'
+ const content = 'This should succeed too.'
- await expect(sandbox.files.write(filename, content)).rejects.toThrowError()
+ await sandbox.files.write(filename, content)
+ const exists = await sandbox.files.exists(filename)
+ assert.isTrue(exists)
+ const readContent = await sandbox.files.read(filename)
+ assert.equal(readContent, content)
})