aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-17 16:00:09 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-17 16:00:21 -0800
commitf927567b9f0c9e374920069005abe01439150975 (patch)
treec14103742bad94e1ae1e3bc36d652516a039373c
parent94ea41a60b3d38db7a92631fe9c64420d5569c0e (diff)
downloadbun-f927567b9f0c9e374920069005abe01439150975.tar.gz
bun-f927567b9f0c9e374920069005abe01439150975.tar.zst
bun-f927567b9f0c9e374920069005abe01439150975.zip
bun install tests shouldn't fail due to terminal colors
-rw-r--r--packages/bun-types/fs/promises.d.ts5
-rw-r--r--test/bun.js/install/bun-install.test.ts73
2 files changed, 36 insertions, 42 deletions
diff --git a/packages/bun-types/fs/promises.d.ts b/packages/bun-types/fs/promises.d.ts
index dc0bce6d0..164ef8db9 100644
--- a/packages/bun-types/fs/promises.d.ts
+++ b/packages/bun-types/fs/promises.d.ts
@@ -676,10 +676,7 @@ declare module "fs/promises" {
* completion callback.
* @since v14.14.0
*/
- export function rm(
- path: PathLike,
- options?: RmOptions,
- ): Promise<void>;
+ export function rm(path: PathLike, options?: RmOptions): Promise<void>;
}
declare module "node:fs/promises" {
diff --git a/test/bun.js/install/bun-install.test.ts b/test/bun.js/install/bun-install.test.ts
index b7413cde3..a48b63579 100644
--- a/test/bun.js/install/bun-install.test.ts
+++ b/test/bun.js/install/bun-install.test.ts
@@ -20,6 +20,13 @@ function resetHanlder() {
};
}
+const env: any = {
+ ...process.env,
+ BUN_DEBUG_QUIET_LOGS: "1",
+ NO_COLOR: "1",
+ FORCE_COLOR: undefined,
+};
+
beforeAll(() => {
server = Bun.serve({
async fetch(request) {
@@ -66,10 +73,7 @@ it("should handle missing package", async () => {
stdout: null,
stdin: "pipe",
stderr: "pipe",
- env: {
- ...process.env,
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ env,
});
expect(stderr).toBeDefined();
const err = await new Response(stderr).text();
@@ -115,10 +119,7 @@ it("should handle @scoped authentication", async () => {
stdout: null,
stdin: "pipe",
stderr: "pipe",
- env: {
- ...process.env,
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ env,
});
expect(stderr).toBeDefined();
const err = await new Response(stderr).text();
@@ -154,10 +155,7 @@ it("should handle workspaces", async () => {
stdout: null,
stdin: "pipe",
stderr: "pipe",
- env: {
- ...process.env,
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ env,
});
expect(stderr).toBeDefined();
const err = await new Response(stderr).text();
@@ -171,7 +169,9 @@ it("should handle workspaces", async () => {
]);
expect(await exited).toBe(0);
expect(requested).toBe(0);
- expect(await readdir(join(package_dir, "node_modules"))).toEqual(["Bar"]);
+ expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([
+ "Bar",
+ ]);
expect(await readlink(join(package_dir, "node_modules", "Bar"))).toBe(
join("..", "bar"),
);
@@ -214,10 +214,7 @@ it("should handle inter-dependency between workspaces", async () => {
stdout: null,
stdin: "pipe",
stderr: "pipe",
- env: {
- ...process.env,
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ env,
});
expect(stderr).toBeDefined();
const err = await new Response(stderr).text();
@@ -232,7 +229,7 @@ it("should handle inter-dependency between workspaces", async () => {
]);
expect(await exited).toBe(0);
expect(requested).toBe(0);
- expect(await readdir(join(package_dir, "node_modules"))).toEqual([
+ expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([
"Bar",
"Baz",
]);
@@ -281,10 +278,7 @@ it("should handle inter-dependency between workspaces (devDependencies)", async
stdout: null,
stdin: "pipe",
stderr: "pipe",
- env: {
- ...process.env,
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ env,
});
expect(stderr).toBeDefined();
const err = await new Response(stderr).text();
@@ -299,7 +293,7 @@ it("should handle inter-dependency between workspaces (devDependencies)", async
]);
expect(await exited).toBe(0);
expect(requested).toBe(0);
- expect(await readdir(join(package_dir, "node_modules"))).toEqual([
+ expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([
"Bar",
"Baz",
]);
@@ -348,10 +342,7 @@ it("should handle inter-dependency between workspaces (optionalDependencies)", a
stdout: null,
stdin: "pipe",
stderr: "pipe",
- env: {
- ...process.env,
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ env,
});
expect(stderr).toBeDefined();
const err = await new Response(stderr).text();
@@ -366,7 +357,7 @@ it("should handle inter-dependency between workspaces (optionalDependencies)", a
]);
expect(await exited).toBe(0);
expect(requested).toBe(0);
- expect(await readdir(join(package_dir, "node_modules"))).toEqual([
+ expect(await await readdirSorted(join(package_dir, "node_modules"))).toEqual([
"Bar",
"Baz",
]);
@@ -407,10 +398,7 @@ it("should ignore peerDependencies within workspaces", async () => {
stdout: null,
stdin: "pipe",
stderr: "pipe",
- env: {
- ...process.env,
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ env,
});
expect(stderr).toBeDefined();
const err = await new Response(stderr).text();
@@ -424,7 +412,9 @@ it("should ignore peerDependencies within workspaces", async () => {
]);
expect(await exited).toBe(0);
expect(requested).toBe(0);
- expect(await readdir(join(package_dir, "node_modules"))).toEqual(["Baz"]);
+ expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([
+ "Baz",
+ ]);
expect(await readlink(join(package_dir, "node_modules", "Baz"))).toBe(
join("..", "packages", "baz"),
);
@@ -467,10 +457,7 @@ it("should handle life-cycle scripts within workspaces", async () => {
stdout: null,
stdin: "pipe",
stderr: "pipe",
- env: {
- ...process.env,
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ env,
});
expect(stderr).toBeDefined();
const err = await new Response(stderr).text();
@@ -486,8 +473,18 @@ it("should handle life-cycle scripts within workspaces", async () => {
]);
expect(await exited).toBe(0);
expect(requested).toBe(0);
- expect(await readdir(join(package_dir, "node_modules"))).toEqual(["Bar"]);
+ expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([
+ "Bar",
+ ]);
expect(await readlink(join(package_dir, "node_modules", "Bar"))).toBe(
join("..", "bar"),
);
});
+
+var readdirSorted = async (
+ ...args: Parameters<typeof readdir>
+): ReturnType<typeof readdir> => {
+ const results = await readdir(...args);
+ results.sort();
+ return results;
+};