diff options
author | 2023-01-17 16:28:49 -0800 | |
---|---|---|
committer | 2023-01-17 16:28:49 -0800 | |
commit | 848658c533afb3f14b1f87591624bdf48ed28979 (patch) | |
tree | d20597478ad80a7983f67ad84320ddb8c2a21d4b | |
parent | 37d2a98331c9481157d8cba1220425a554d1425f (diff) | |
download | bun-848658c533afb3f14b1f87591624bdf48ed28979.tar.gz bun-848658c533afb3f14b1f87591624bdf48ed28979.tar.zst bun-848658c533afb3f14b1f87591624bdf48ed28979.zip |
[test] Add helper for bun env
-rw-r--r-- | test/bun.js/bunEnv.ts | 6 | ||||
-rw-r--r-- | test/bun.js/install/bun-install.test.ts | 8 | ||||
-rw-r--r-- | test/bun.js/log-test.test.ts | 9 |
3 files changed, 11 insertions, 12 deletions
diff --git a/test/bun.js/bunEnv.ts b/test/bun.js/bunEnv.ts new file mode 100644 index 000000000..2fe33a4ea --- /dev/null +++ b/test/bun.js/bunEnv.ts @@ -0,0 +1,6 @@ +export const bunEnv: any = { + ...process.env, + BUN_DEBUG_QUIET_LOGS: "1", + NO_COLOR: "1", + FORCE_COLOR: undefined, +}; diff --git a/test/bun.js/install/bun-install.test.ts b/test/bun.js/install/bun-install.test.ts index a48b63579..8de41fbc8 100644 --- a/test/bun.js/install/bun-install.test.ts +++ b/test/bun.js/install/bun-install.test.ts @@ -11,6 +11,7 @@ import { bunExe } from "bunExe"; import { mkdir, mkdtemp, readdir, readlink, rm, writeFile } from "fs/promises"; import { join } from "path"; import { tmpdir } from "os"; +import { bunEnv } from "bunEnv"; let handler, package_dir, requested, server; @@ -20,12 +21,7 @@ function resetHanlder() { }; } -const env: any = { - ...process.env, - BUN_DEBUG_QUIET_LOGS: "1", - NO_COLOR: "1", - FORCE_COLOR: undefined, -}; +const env = bunEnv; beforeAll(() => { server = Bun.serve({ diff --git a/test/bun.js/log-test.test.ts b/test/bun.js/log-test.test.ts index 62098d97c..29f541e32 100644 --- a/test/bun.js/log-test.test.ts +++ b/test/bun.js/log-test.test.ts @@ -3,6 +3,7 @@ import { basename, dirname, join } from "path"; import * as fs from "fs"; import { readableStreamToText, spawnSync } from "bun"; import { bunExe } from "bunExe"; +import { bunEnv } from "bunEnv"; it("should not log .env when quiet", async () => { writeDirectoryTree("/tmp/log-test-silent", { @@ -13,9 +14,7 @@ it("should not log .env when quiet", async () => { const { stderr } = spawnSync({ cmd: [bunExe(), "index.ts"], cwd: "/tmp/log-test-silent", - env: { - BUN_DEBUG_QUIET_LOGS: "1", - }, + env: bunEnv, }); expect(stderr!.toString()).toBe(""); @@ -31,9 +30,7 @@ it("should log .env by default", async () => { const { stderr } = spawnSync({ cmd: [bunExe(), "index.ts"], cwd: "/tmp/log-test-silent", - env: { - BUN_DEBUG_QUIET_LOGS: "1", - }, + env: bunEnv, }); expect(stderr?.toString().includes(".env")).toBe(true); |