mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
68 lines
1.2 KiB
TypeScript
68 lines
1.2 KiB
TypeScript
import { spawnSync } from "bun";
|
|
import { expect, test } from "bun:test";
|
|
import { bunEnv, bunExe } from "harness";
|
|
import { join } from "path";
|
|
|
|
test("reportError", () => {
|
|
const cwd = import.meta.dir;
|
|
const { stderr } = spawnSync({
|
|
cmd: [bunExe(), join(import.meta.dir, "reportError.ts")],
|
|
cwd,
|
|
env: {
|
|
...bunEnv,
|
|
// this is default enabled in debug, affects output.
|
|
BUN_JSC_showPrivateScriptsInStackTraces: "0",
|
|
},
|
|
});
|
|
let output = stderr.toString().replaceAll(cwd, "").replaceAll("\\", "/");
|
|
// remove bun version from output
|
|
output = output.split("\n").slice(0, -2).join("\n");
|
|
|
|
expect(output.replaceAll("\\", "/").replaceAll("/reportError.ts", "[file]")).toMatchInlineSnapshot(
|
|
`
|
|
"1 | reportError(new Error("reportError Test!"));
|
|
^
|
|
error: reportError Test!
|
|
at [file]:1:13
|
|
at loadAndEvaluateModule (2:1)
|
|
error: true
|
|
true
|
|
error: false
|
|
false
|
|
error: null
|
|
null
|
|
error: 123
|
|
123
|
|
error: Infinity
|
|
Infinity
|
|
error: NaN
|
|
NaN
|
|
error: NaN
|
|
NaN
|
|
error
|
|
|
|
error
|
|
Uint8Array(1) [ 0 ]
|
|
error
|
|
Uint8Array(0) []
|
|
error
|
|
ArrayBuffer(0) []
|
|
error
|
|
ArrayBuffer(1) [ 0 ]
|
|
error: string
|
|
string
|
|
error
|
|
[]
|
|
error
|
|
[ 123, null ]
|
|
error
|
|
{}
|
|
error
|
|
[
|
|
{}
|
|
]
|
|
"
|
|
`,
|
|
);
|
|
});
|