Skip to content

Commit 1cb1766

Browse files
committed
Update JS tests
1 parent 6ebbaca commit 1cb1766

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

js/tests/envVars.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { expect } from 'vitest'
22

3-
import { isDebug, sandboxTest } from './setup'
3+
import { isDebug, sandboxTest, timeoutMs } from './setup'
44
import { Sandbox } from '../src'
55

66
// Skip this test if we are running in debug mode — the pwd and user in the testing docker container are not the same as in the actual sandbox.
77
sandboxTest.skipIf(isDebug)('env vars', async () => {
88
const sandbox = await Sandbox.create({
99
envs: { TEST_ENV_VAR: 'supertest' },
10+
autoPause: true,
11+
timeoutMs,
1012
})
1113

1214
try {
@@ -32,6 +34,8 @@ sandboxTest('env vars on sandbox', async ({ sandbox }) => {
3234
sandboxTest('env vars on sandbox override', async () => {
3335
const sandbox = await Sandbox.create({
3436
envs: { FOO: 'bar', SBX: 'value' },
37+
autoPause: true,
38+
timeoutMs,
3539
})
3640

3741
try {

js/tests/reconnect.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { expect } from 'vitest'
22

33
import { Sandbox } from '../src'
4-
import { sandboxTest } from './setup'
4+
import { sandboxTest, timeoutMs } from './setup'
55

66
sandboxTest('reconnect', async ({ sandbox }) => {
7-
sandbox = await Sandbox.connect(sandbox.sandboxId)
7+
sandbox = await Sandbox.connect(sandbox.sandboxId, { timeoutMs, autoPause: true })
88

99
const result = await sandbox.runCode('x =1; x')
1010

js/tests/runtimes/bun/run.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from 'bun:test'
33
import { Sandbox } from '../../../src'
44

55
test('Bun test', async () => {
6-
const sbx = await Sandbox.create({ timeoutMs: 5_000 })
6+
const sbx = await Sandbox.create({ timeoutMs: 5_000, autoPause: true })
77

88
try {
99
const result = await sbx.runCode('print("Hello, World!")')

js/tests/runtimes/deno/run.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ await load({ envPath: '.env', export: true })
66
import { Sandbox } from '../../../dist/index.mjs'
77

88
Deno.test('Deno test', async () => {
9-
const sbx = await Sandbox.create({ timeoutMs: 5_000 })
9+
const sbx = await Sandbox.create({ timeoutMs: 5_000, autoPause: true })
1010

1111
try {
1212
const result = await sbx.runCode('print("Hello, World!")')

js/tests/setup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Sandbox } from '../src'
22
import { test as base } from 'vitest'
33

4-
const timeoutMs = 60_000
4+
export const timeoutMs = 60_000
55

66
interface SandboxFixture {
77
sandbox: Sandbox
88
}
99

1010
export const sandboxTest = base.extend<SandboxFixture>({
1111
sandbox: [
12-
async ({}, use) => {
13-
const sandbox = await Sandbox.create({ timeoutMs })
12+
async ({ }, use) => {
13+
const sandbox = await Sandbox.create({ timeoutMs, autoPause: true })
1414
try {
1515
await use(sandbox)
1616
} finally {

0 commit comments

Comments
 (0)