1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import { test, expect } from "bun:test";
import { bunEnv, bunExe } from "harness";
import { join } from "path";
// This also tests __dirname and __filename
test("require.cache", () => {
const { stdout, exitCode } = Bun.spawnSync({
cmd: [bunExe(), "run", join(import.meta.dir, "require-cache-fixture.cjs")],
env: bunEnv,
stderr: "inherit",
});
expect(stdout.toString().trim()).toEndWith("--pass--");
expect(exitCode).toBe(0);
});
// https://github.com/oven-sh/bun/issues/5188
test("require.cache does not include unevaluated modules", () => {
const { stdout, exitCode } = Bun.spawnSync({
cmd: [bunExe(), "run", join(import.meta.dir, "require-cache-bug-5188.js")],
env: bunEnv,
stderr: "inherit",
});
expect(stdout.toString().trim()).toEndWith("--pass--");
expect(exitCode).toBe(0);
});
|