Files
bun.sh/test/js/bun/shell/bunshell-default.test.ts
dave caruso c177e054f5 feat!: shell will now throw on error by default (#9720)
* 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>
2024-03-31 16:13:59 -07:00

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");
}
});