Files
bun.sh/test/js/bun/util/bun-isMainThread.test.js
2024-02-01 13:45:47 -08:00

16 lines
450 B
JavaScript

import { test, expect } from "bun:test";
import { bunEnv, bunExe } from "harness";
test("Bun.isMainThread", () => {
expect(Bun.isMainThread).toBeTrue();
const { stdout, exitCode } = Bun.spawnSync({
cmd: [bunExe(), import.meta.resolveSync("./main-worker-file.js")],
stderr: "inherit",
stdout: "pipe",
env: bunEnv,
});
expect(exitCode).toBe(0);
expect(stdout.toString()).toBe("isMainThread true\nisMainThread false\n");
});