-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathsetup.ts
More file actions
38 lines (33 loc) · 923 Bytes
/
Copy pathsetup.ts
File metadata and controls
38 lines (33 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Sandbox } from '../src'
import { test as base } from 'vitest'
import { template } from './template'
interface SandboxFixture {
sandbox: Sandbox
}
export const sandboxTest = base.extend<SandboxFixture>({
sandbox: [
async ({ }, use) => {
const sandbox = await Sandbox.create(template)
try {
await use(sandbox)
} finally {
try {
await sandbox.kill()
} catch (err) {
if (!isDebug) {
console.warn(
'Failed to kill sandbox — this is expected if the test runs with local envd.'
)
}
}
}
},
{ auto: false },
],
})
export const isDebug = process.env.E2B_DEBUG !== undefined
export const isIntegrationTest = process.env.E2B_INTEGRATION_TEST !== undefined
export async function wait(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
export { template }