Skip to content

Commit 9f44d34

Browse files
committed
added test for typescript kernel failure
1 parent abac1f7 commit 9f44d34

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

js/tests/defaultKernels.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ import { expect } from 'vitest'
33
import { sandboxTest } from './setup'
44

55
sandboxTest('test js kernel', async ({ sandbox }) => {
6-
const output = await sandbox.runCode('console.log("Hello World!")', { language: 'js' })
6+
const output = await sandbox.runCode('console.log("Hello World!")', {
7+
language: 'js',
8+
})
79
expect(output.logs.stdout).toEqual(['Hello World!\n'])
810
})
911

1012
sandboxTest('test ts kernel', async ({ sandbox }) => {
11-
const output = await sandbox.runCode('const message: string = "Hello World!"; console.log(message)', { language: 'ts' })
13+
const output = await sandbox.runCode(
14+
'const message: string = "Hello World!"; console.log(message)',
15+
{ language: 'ts' }
16+
)
1217
expect(output.logs.stdout).toEqual(['Hello World!\n'])
1318
})
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/tests/async/test_async_default_kernels.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ async def test_ts_kernel(async_sandbox: AsyncSandbox):
1212
"const message: string = 'Hello, World!'; console.log(message);", language="ts"
1313
)
1414
assert execution.logs.stdout == ["Hello, World!\n"]
15+
16+
async def test_ts_kernel_errors(async_sandbox: AsyncSandbox):
17+
execution = await async_sandbox.run_code(
18+
"import x from 'module';", language="ts"
19+
)
20+
assert execution.error is not None
21+
assert execution.error.name == "TypeScriptCompilerError"

python/tests/sync/test_default_kernels.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ def test_java_kernel(sandbox: Sandbox):
2424
def test_ts_kernel(sandbox: Sandbox):
2525
execution = sandbox.run_code("const message: string = 'Hello, World!'; console.log(message)", language="ts")
2626
assert execution.logs.stdout == ["Hello, World!\n"]
27+
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)