Skip to content

Commit

Permalink
Fix tests that pass but generate annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Electroid committed Jun 9, 2023
1 parent 0eb5103 commit 99485be
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 26 deletions.
3 changes: 2 additions & 1 deletion test/js/bun/http/serve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 25 additions & 0 deletions test/js/bun/util/__snapshots__/reportError.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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
"
`;
25 changes: 0 additions & 25 deletions test/js/bun/util/reportError.test.js

This file was deleted.

14 changes: 14 additions & 0 deletions test/js/bun/util/reportError.test.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions test/js/bun/util/reportError.ts
Original file line number Diff line number Diff line change
@@ -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([{}]);

0 comments on commit 99485be

Please sign in to comment.