Files
bun.sh/test/js/bun/util/bun-isMainThread.test.js
2023-07-27 22:28:28 -07: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");
});