aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
authorGravatar Fran Zekan <zekan.fran369@gmail.com> 2023-03-04 02:49:32 +0100
committerGravatar GitHub <noreply@github.com> 2023-03-03 17:49:32 -0800
commit7c367ff687554c39baf1d27218c9c8bc7129650b (patch)
tree41ac0661ffa2d5fc3a6de7591551d5e3b64185bc /test/bun.js
parent0f8f484e21e3ebafaf62370421f6296eaca262fe (diff)
downloadbun-7c367ff687554c39baf1d27218c9c8bc7129650b.tar.gz
bun-7c367ff687554c39baf1d27218c9c8bc7129650b.tar.zst
bun-7c367ff687554c39baf1d27218c9c8bc7129650b.zip
fix(bunx): Show usage when calling bunx without arguments (#2295)
* Make sure to return a helpful error message if no args are passed to bunx * Add tests for bunx without args
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/install/bunx.test.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/bun.js/install/bunx.test.ts b/test/bun.js/install/bunx.test.ts
index 76cd944a1..941f006bb 100644
--- a/test/bun.js/install/bunx.test.ts
+++ b/test/bun.js/install/bunx.test.ts
@@ -53,6 +53,25 @@ it("should install and run specified version", async () => {
expect(await exited).toBe(0);
});
+it("should output usage if no arguments are passed", async () => {
+ const { stdout, stderr, exited } = spawn({
+ cmd: [bunExe(), "x"],
+ cwd: x_dir,
+ stdout: null,
+ stdin: "pipe",
+ stderr: "pipe",
+ env,
+ });
+
+ expect(stderr).toBeDefined();
+ const err = await new Response(stderr).text();
+ expect(err).toContain("usage: ");
+ expect(stdout).toBeDefined();
+ const out = await new Response(stdout).text();
+ expect(out).toHaveLength(0);
+ expect(await exited).toBe(1);
+});
+
it("should download dependency to run local file", async () => {
await writeFile(
join(x_dir, "test.js"),