Files
bun.sh/test/js/bun/util/bun-main.test.ts
190n a1f756fea9 Fix running bun test on multiple node:test tests (#19354)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-24 11:48:55 -07:00

23 lines
719 B
TypeScript

import { describe, expect, test } from "bun:test";
import { join } from "node:path";
import "../../../harness"; // for expect().toRun()
describe("Bun.main", () => {
test("can be overridden", () => {
expect(Bun.main).toBeString();
const override = { foo: "bar" };
// types say Bun.main is a readonly string, but we want to write it
// and check it can be set to a non-string
(Bun as any).main = override;
expect(Bun.main as any).toBe(override);
});
test("override is reset when switching to a new test file", () => {
expect([
"test",
join(import.meta.dir, "bun-main-test-fixture-1.ts"),
join(import.meta.dir, "bun-main-test-fixture-2.ts"),
]).toRun();
});
});