Fix tests that pass but generate annotation

This commit is contained in:
Ashcon Partovi
2023-06-09 05:53:23 -07:00
parent 0eb5103642
commit 99485bec4c
5 changed files with 59 additions and 26 deletions

View File

@@ -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,

View 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
"
`;

View File

@@ -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--");
});

View 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();
});

View 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([{}]);