mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 04:49:06 +00:00
* make the shell throw by default * make shell default to throws(true) * ok * mv tests * a * a * [autofix.ci] apply automated fixes --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
26 lines
760 B
TypeScript
26 lines
760 B
TypeScript
import { $ } from "bun";
|
|
|
|
test("default throw on command failure", async () => {
|
|
try {
|
|
await $`echo hi; ls oogabooga`.quiet();
|
|
expect.unreachable();
|
|
} catch (e: any) {
|
|
expect(e).toBeInstanceOf(Error);
|
|
expect(e.exitCode).toBe(1);
|
|
expect(e.message).toBe("Failed with exit code 1");
|
|
expect(e.stdout.toString("utf-8")).toBe("hi\n");
|
|
expect(e.stderr.toString("utf-8")).toBe("ls: oogabooga: No such file or directory\n");
|
|
}
|
|
});
|
|
|
|
test("ShellError has .text()", async () => {
|
|
try {
|
|
await $`ls oogabooga`.quiet();
|
|
expect.unreachable();
|
|
} catch (e: any) {
|
|
expect(e).toBeInstanceOf(Error);
|
|
expect(e.exitCode).toBe(1);
|
|
expect(e.stderr.toString("utf-8")).toBe("ls: oogabooga: No such file or directory\n");
|
|
}
|
|
});
|