mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Fix tests that pass but generate annotation
This commit is contained in:
@@ -348,7 +348,8 @@ describe("streaming", () => {
|
||||
});
|
||||
|
||||
// Also verifies error handler reset in `.reload()` due to test above
|
||||
it("text from JS throws on start with no error handler", async () => {
|
||||
// TODO: rewrite test so uncaught error does not create an annotation in CI
|
||||
it.skip("text from JS throws on start with no error handler", async () => {
|
||||
await runTest(
|
||||
{
|
||||
error: undefined,
|
||||
|
||||
25
test/js/bun/util/__snapshots__/reportError.test.ts.snap
Normal file
25
test/js/bun/util/__snapshots__/reportError.test.ts.snap
Normal file
@@ -0,0 +1,25 @@
|
||||
// Bun Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`reportError 1`] = `
|
||||
"1 | reportError(new Error("reportError Test!"));
|
||||
^
|
||||
error: reportError Test!
|
||||
at /reportError.ts:1:12
|
||||
error: true
|
||||
error: false
|
||||
error: null
|
||||
error: 123
|
||||
error: Infinity
|
||||
error: NaN
|
||||
error
|
||||
error
|
||||
error
|
||||
error
|
||||
error
|
||||
error: string
|
||||
error
|
||||
error
|
||||
error
|
||||
error
|
||||
"
|
||||
`;
|
||||
@@ -1,25 +0,0 @@
|
||||
import { it } from "bun:test";
|
||||
|
||||
it("reportError", () => {
|
||||
console.log("---BEGIN REPORT ERROR TEST--");
|
||||
// make sure we don't crash when given non-sensical types
|
||||
reportError(new Error("reportError Test!"));
|
||||
reportError(true);
|
||||
reportError(false);
|
||||
reportError(null);
|
||||
reportError(123);
|
||||
reportError(Infinity);
|
||||
reportError(NaN);
|
||||
reportError(-NaN);
|
||||
reportError("");
|
||||
reportError(new Uint8Array(1));
|
||||
reportError(new Uint8Array(0));
|
||||
reportError(new ArrayBuffer(0));
|
||||
reportError(new ArrayBuffer(1));
|
||||
reportError("string");
|
||||
reportError([]);
|
||||
reportError([123, null]);
|
||||
reportError({});
|
||||
reportError([{}]);
|
||||
console.log("---END REPORT ERROR TEST--");
|
||||
});
|
||||
14
test/js/bun/util/reportError.test.ts
Normal file
14
test/js/bun/util/reportError.test.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { test, expect } from "bun:test";
|
||||
import { spawnSync } from "bun";
|
||||
import { bunEnv, bunExe } from "harness";
|
||||
|
||||
test("reportError", () => {
|
||||
const cwd = import.meta.dir;
|
||||
const { stderr } = spawnSync({
|
||||
cmd: [bunExe(), new URL("./reportError.ts", import.meta.url).pathname],
|
||||
cwd,
|
||||
env: bunEnv,
|
||||
});
|
||||
const output = stderr.toString().replaceAll(cwd, "");
|
||||
expect(output).toMatchSnapshot();
|
||||
});
|
||||
18
test/js/bun/util/reportError.ts
Normal file
18
test/js/bun/util/reportError.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
reportError(new Error("reportError Test!"));
|
||||
reportError(true);
|
||||
reportError(false);
|
||||
reportError(null);
|
||||
reportError(123);
|
||||
reportError(Infinity);
|
||||
reportError(NaN);
|
||||
reportError(-NaN);
|
||||
reportError("");
|
||||
reportError(new Uint8Array(1));
|
||||
reportError(new Uint8Array(0));
|
||||
reportError(new ArrayBuffer(0));
|
||||
reportError(new ArrayBuffer(1));
|
||||
reportError("string");
|
||||
reportError([]);
|
||||
reportError([123, null]);
|
||||
reportError({});
|
||||
reportError([{}]);
|
||||
Reference in New Issue
Block a user