-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathreportError.test.ts
66 lines (63 loc) · 1.15 KB
/
reportError.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
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
[
{}
]
"
`,
);
});