-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.test.ts
32 lines (28 loc) · 1.17 KB
/
esbuild.test.ts
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
import { createEsbuilder } from "./esbuild";
import { describe, it, expect } from 'vitest';
describe('JavaScript and TypeScript Compiler Tests', () => {
it('should compile JavaScript code correctly', async () => {
const [javaScriptCompiler] = createEsbuilder();
const result = await javaScriptCompiler({
rawCode: `1 + 1`,
entryPoint: 'index.js'
});
expect(result).toBe("Compilation failed: The \"wasmURL\" option only works in the browser");
});
it('should compile TypeScript code correctly', async () => {
const [javaScriptCompiler] = createEsbuilder();
const result = await javaScriptCompiler({
rawCode: `let num: number = 1; num + 1;`,
entryPoint: 'index.ts'
});
expect(result).toBe("Compilation failed: The \"wasmURL\" option only works in the browser");
});
it('should compile JSX code correctly', async () => {
const [javaScriptCompiler] = createEsbuilder();
const result = await javaScriptCompiler({
rawCode: `const element = <div>Hello World</div>; element.type;`,
entryPoint: 'index.jsx'
});
expect(result).toBe("Compilation failed: The \"wasmURL\" option only works in the browser");
});
});