Files
bun.sh/test/js/web/console/console-timeLog.test.ts
2024-09-03 21:32:52 -07:00

22 lines
706 B
TypeScript

import { file, spawn } from "bun";
import { expect, it } from "bun:test";
import { bunEnv, bunExe } from "harness";
import { join } from "node:path";
it("should log to console correctly", async () => {
const { stderr, exited } = spawn({
cmd: [bunExe(), join(import.meta.dir, "console-timeLog.js")],
stdin: null,
stdout: "pipe",
stderr: "pipe",
env: bunEnv,
});
expect(await exited).toBe(0);
const outText = await new Response(stderr).text();
const expectedText = (await file(join(import.meta.dir, "console-timeLog.expected.txt")).text()).replaceAll(
"\r\n",
"\n",
);
expect(outText.replace(/^\[.+?s\] /gm, "")).toBe(expectedText.replace(/^\[.+?s\] /gm, ""));
});