diff options
Diffstat (limited to 'test/bun.js/esbuild-child_process.test.ts')
| -rw-r--r-- | test/bun.js/esbuild-child_process.test.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/bun.js/esbuild-child_process.test.ts b/test/bun.js/esbuild-child_process.test.ts new file mode 100644 index 000000000..0d357a940 --- /dev/null +++ b/test/bun.js/esbuild-child_process.test.ts @@ -0,0 +1,46 @@ +import { transform, transformSync } from "esbuild"; +import { describe, it, expect } from "bun:test"; + +describe("child_process.spawn - esbuild", () => { + it("should transform successfully", async () => { + const result = await transform("console.log('hello world')", { + loader: "js", + target: "node12", + }); + expect(result.code).toBe('console.log("hello world");\n'); + }); + + it("works for input exceeding the pipe capacity", async () => { + const hugeString = `console.log(${JSON.stringify("a".repeat(1000000))});`; + const result = await transform(hugeString, { + loader: "js", + target: "node12", + }); + expect(result.code).toBe(hugeString + "\n"); + }); +}); + +describe("child_process.spawnSync - esbuild", () => { + it("should transform successfully", () => { + const result = transformSync("console.log('hello world')", { + loader: "js", + target: "node12", + }); + expect(result.code).toBe('console.log("hello world");\n'); + }); + + // This test is failing with the following error: + // error: Error + // path: "/Users/jarred/Code/bun/test/bun.js/node_modules/esbuild-darwin-arm64/bin/esbuild" + // code: "13" + // syscall: "spawnSync" + // errno: -1 + // it("works for input exceeding the pipe capacity", () => { + // const hugeString = `console.log(${JSON.stringify("a".repeat(100000))});`; + // const result = transformSync(hugeString, { + // loader: "js", + // target: "node12", + // }); + // expect(result.code).toBe(hugeString + "\n"); + // }); +}); |
