-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathdefaultKernels.test.ts
More file actions
46 lines (41 loc) · 1.08 KB
/
defaultKernels.test.ts
File metadata and controls
46 lines (41 loc) · 1.08 KB
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
39
40
41
42
43
44
45
46
import { expect } from 'vitest'
import { sandboxTest } from './setup'
sandboxTest('test js kernel', async ({ sandbox }) => {
const output = await sandbox.runCode('console.log("Hello World!")', {
language: 'js',
})
expect(output.logs.stdout).toEqual(['Hello World!\n'])
})
sandboxTest('test esm imports', async ({ sandbox }) => {
const output = await sandbox.runCode(
`
import { readFileSync } from 'fs'
console.log(typeof readFileSync)
`,
{
language: 'js',
}
)
expect(output.logs.stdout).toEqual(['function\n'])
})
sandboxTest(
'test top-level await and promise resolution',
async ({ sandbox }) => {
const output = await sandbox.runCode(
`
await Promise.resolve('Hello World!')
`,
{
language: 'js',
}
)
expect(output.text).toEqual('Hello World!')
}
)
sandboxTest('test ts kernel', async ({ sandbox }) => {
const output = await sandbox.runCode(
'const message: string = "Hello World!"; console.log(message)',
{ language: 'ts' }
)
expect(output.logs.stdout).toEqual(['Hello World!\n'])
})