Skip to content

Commit cd0e3ef

Browse files
authored
Merge branch 'main' into environment-variables-are-not-accessible-when-running-r-code-e2b-1977
2 parents f34cf8f + 85cac91 commit cd0e3ef

File tree

11 files changed

+305
-317
lines changed

11 files changed

+305
-317
lines changed

js/tests/defaultKernels.test.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,38 @@ sandboxTest('test js kernel', async ({ sandbox }) => {
99
expect(output.logs.stdout).toEqual(['Hello World!\n'])
1010
})
1111

12+
sandboxTest('test esm imports', async ({ sandbox }) => {
13+
const output = await sandbox.runCode(
14+
`
15+
import { readFileSync } from 'fs'
16+
console.log(typeof readFileSync)
17+
`,
18+
{
19+
language: 'js',
20+
}
21+
)
22+
expect(output.logs.stdout).toEqual(['function\n'])
23+
})
24+
25+
sandboxTest(
26+
'test top-level await and promise resolution',
27+
async ({ sandbox }) => {
28+
const output = await sandbox.runCode(
29+
`
30+
await Promise.resolve('Hello World!')
31+
`,
32+
{
33+
language: 'js',
34+
}
35+
)
36+
expect(output.text).toEqual('Hello World!')
37+
}
38+
)
39+
1240
sandboxTest('test ts kernel', async ({ sandbox }) => {
1341
const output = await sandbox.runCode(
1442
'const message: string = "Hello World!"; console.log(message)',
1543
{ language: 'ts' }
1644
)
1745
expect(output.logs.stdout).toEqual(['Hello World!\n'])
1846
})
19-
20-
sandboxTest('test ts kernel errors', async ({ sandbox }) => {
21-
const output = await sandbox.runCode('import x from "module";', {
22-
language: 'typescript',
23-
})
24-
expect(output.error?.name).toEqual('TypeScriptCompilerError')
25-
})

python/poetry.lock

Lines changed: 10 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/tests/async/test_async_default_kernels.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ async def test_js_kernel(async_sandbox: AsyncSandbox):
77
)
88
assert execution.logs.stdout == ["Hello, World!\n"]
99

10+
async def test_js_esm_imports(async_sandbox: AsyncSandbox):
11+
execution = await async_sandbox.run_code("""
12+
import { readFileSync } from 'fs'
13+
console.log(typeof readFileSync)
14+
""", language="js")
15+
assert execution.logs.stdout == ["function\n"]
16+
17+
18+
async def test_js_top_level_await(async_sandbox: AsyncSandbox):
19+
execution = await async_sandbox.run_code("""
20+
await Promise.resolve('Hello World!')
21+
""", language="js")
22+
assert execution.text == "Hello World!"
23+
1024

1125
async def test_ts_kernel(async_sandbox: AsyncSandbox):
1226
execution = await async_sandbox.run_code(
1327
"const message: string = 'Hello, World!'; console.log(message);", language="ts"
1428
)
1529
assert execution.logs.stdout == ["Hello, World!\n"]
16-
17-
18-
async def test_ts_kernel_errors(async_sandbox: AsyncSandbox):
19-
execution = await async_sandbox.run_code(
20-
"import x from 'module';", language="ts"
21-
)
22-
assert execution.error is not None
23-
assert execution.error.name == "TypeScriptCompilerError"

python/tests/sync/test_default_kernels.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,23 @@ def test_java_kernel(sandbox: Sandbox):
2020
assert execution.logs.stdout[0] == "Hello, World!"
2121

2222

23+
def test_js_esm_imports(sandbox: Sandbox):
24+
execution = sandbox.run_code("""
25+
import { readFileSync } from 'fs'
26+
console.log(typeof readFileSync)
27+
""", language="js")
28+
assert execution.logs.stdout == ["function\n"]
29+
30+
31+
def test_js_top_level_await(sandbox: Sandbox):
32+
execution = sandbox.run_code("""
33+
await Promise.resolve('Hello World!')
34+
""", language="js")
35+
assert execution.text == "Hello World!"
36+
37+
2338
@pytest.mark.skip_debug()
2439
def test_ts_kernel(sandbox: Sandbox):
2540
execution = sandbox.run_code("const message: string = 'Hello, World!'; console.log(message)", language="ts")
2641
assert execution.logs.stdout == ["Hello, World!\n"]
2742

28-
29-
def test_ts_kernel_errors(sandbox: Sandbox):
30-
execution = sandbox.run_code("import x from 'module';", language="ts")
31-
assert execution.error is not None
32-
assert execution.error.name == "TypeScriptCompilerError"

0 commit comments

Comments
 (0)