chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:47:58 +08:00
commit b16403ea71
789 changed files with 115226 additions and 0 deletions
@@ -0,0 +1,38 @@
import { expect, inject, test } from 'vitest'
import { render } from 'vitest-browser-react'
import React from 'react'
import { useEffect, useState } from 'react'
import { Sandbox } from '../../../src'
import { template } from '../../template'
function E2BTest() {
const [text, setText] = useState<string>()
useEffect(() => {
const getText = async () => {
const sandbox = await Sandbox.create(template, {
apiKey: inject('E2B_API_KEY'),
domain: inject('E2B_DOMAIN'),
})
try {
await sandbox.commands.run('echo "Hello World" > hello.txt')
const content = await sandbox.files.read('hello.txt')
setText(content)
} finally {
await sandbox.kill()
}
}
getText()
}, [])
return <div>{text}</div>
}
test('browser test', async () => {
const screen = await render(<E2BTest />)
await expect
.element(screen.getByText('Hello World'), { timeout: 30_000 })
.toBeInTheDocument()
}, 40_000)
@@ -0,0 +1,30 @@
import { expect, test } from 'bun:test'
import { Sandbox } from '../../../src'
import { template } from '../../template'
test(
'Bun test',
async () => {
const sbx = await Sandbox.create(template, { timeoutMs: 5_000 })
try {
const isRunning = await sbx.isRunning()
expect(isRunning).toBeTruthy()
const text = 'Hello, World!'
const cmd = await sbx.commands.run(`echo "${text}"`)
expect(cmd.exitCode).toBe(0)
expect(cmd.stdout).toEqual(`${text}\n`)
await sbx.files.write('test.txt', text)
const test = await sbx.files.read('test.txt')
expect(test).toEqual(text)
} finally {
await sbx.kill()
}
},
{ timeout: 20_000 }
)
@@ -0,0 +1,27 @@
import {
assert,
assertEquals,
} from 'https://deno.land/std@0.224.0/assert/mod.ts'
import { load } from 'https://deno.land/std@0.224.0/dotenv/mod.ts'
await load({ envPath: '.env', export: true })
import { Sandbox } from '../../../dist/index.mjs'
import { template } from '../../template'
Deno.test('Deno test', async () => {
const sbx = await Sandbox.create(template, { timeoutMs: 5_000 })
try {
const isRunning = await sbx.isRunning()
assert(isRunning)
const text = 'Hello, World!'
const cmd = await sbx.commands.run(`echo "${text}"`)
assertEquals(cmd.exitCode, 0)
assertEquals(cmd.stdout, `${text}\n`)
} finally {
await sbx.kill()
}
})