aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/install/bunx.test.ts41
1 files changed, 40 insertions, 1 deletions
diff --git a/test/bun.js/install/bunx.test.ts b/test/bun.js/install/bunx.test.ts
index 941f006bb..e43dd673d 100644
--- a/test/bun.js/install/bunx.test.ts
+++ b/test/bun.js/install/bunx.test.ts
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, expect, it } from "bun:test";
import { bunExe } from "bunExe";
import { bunEnv as env } from "bunEnv";
import { realpathSync } from "fs";
-import { mkdtemp, rm, writeFile } from "fs/promises";
+import { mkdtemp, realpath, rm, writeFile } from "fs/promises";
import { tmpdir } from "os";
import { join } from "path";
import { readdirSorted } from "./dummy.registry";
@@ -72,6 +72,45 @@ it("should output usage if no arguments are passed", async () => {
expect(await exited).toBe(1);
});
+it("should work for @scoped packages", async () => {
+ await rm(join(await realpath(tmpdir()), "@withfig"), { force: true, recursive: true });
+ // without cache
+ const withoutCache = spawn({
+ cmd: [bunExe(), "x", "@withfig/autocomplete-tools", "--help"],
+ cwd: x_dir,
+ stdout: null,
+ stdin: "pipe",
+ stderr: "pipe",
+ env,
+ });
+
+ expect(withoutCache.stderr).toBeDefined();
+ let err = await new Response(withoutCache.stderr).text();
+ expect(err).not.toContain("error");
+ expect(withoutCache.stdout).toBeDefined();
+ let out = await new Response(withoutCache.stdout).text();
+ expect(out.trim()).toContain("Usage: @withfig/autocomplete-tool");
+ expect(await withoutCache.exited).toBe(0);
+
+ // cached
+ const cached = spawn({
+ cmd: [bunExe(), "x", "@withfig/autocomplete-tools", "--help"],
+ cwd: x_dir,
+ stdout: null,
+ stdin: "pipe",
+ stderr: "pipe",
+ env,
+ });
+
+ expect(cached.stderr).toBeDefined();
+ err = await new Response(cached.stderr).text();
+ expect(err).not.toContain("error");
+ expect(cached.stdout).toBeDefined();
+ out = await new Response(cached.stdout).text();
+ expect(out.trim()).toContain("Usage: @withfig/autocomplete-tool");
+ expect(await cached.exited).toBe(0);
+});
+
it("should download dependency to run local file", async () => {
await writeFile(
join(x_dir, "test.js"),