Files
bun.sh/test/cli/run/run_command.test.ts
2024-05-21 13:51:47 -07:00

33 lines
923 B
TypeScript

import { describe, test, expect } from "bun:test";
import { spawnSync } from "bun";
import { bunEnv, bunExe, bunRun, isWindows } from "harness";
import { writeFileSync, rmSync } from "fs";
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);
}
});