mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
33 lines
923 B
TypeScript
33 lines
923 B
TypeScript
import { spawnSync } from "bun";
|
|
import { describe, expect, test } from "bun:test";
|
|
import { rmSync, writeFileSync } from "fs";
|
|
import { bunEnv, bunExe, bunRun, isWindows } from "harness";
|
|
|
|
let cwd: string;
|
|
|
|
describe("bun", () => {
|
|
test("should error with missing script", () => {
|
|
const { exitCode, stdout, stderr } = spawnSync({
|
|
cwd,
|
|
cmd: [bunExe(), "run", "dev"],
|
|
env: bunEnv,
|
|
stdout: "pipe",
|
|
stderr: "pipe",
|
|
});
|
|
expect(stdout.toString()).toBeEmpty();
|
|
expect(stderr.toString()).toMatch(/Script not found/);
|
|
expect(exitCode).toBe(1);
|
|
});
|
|
});
|
|
|
|
test.if(isWindows)("[windows] A file in drive root runs", () => {
|
|
const path = "C:\\root-file" + Math.random().toString().slice(2) + ".js";
|
|
try {
|
|
writeFileSync(path, "console.log(`PASS`);");
|
|
const { stdout } = bunRun("C:\\root-file.js", {});
|
|
expect(stdout).toBe("PASS");
|
|
} catch {
|
|
rmSync(path);
|
|
}
|
|
});
|