Files
bun.sh/test/js/bun/util/inspect-error.test.js
Jarred Sumner bf32d36e4c Cleanup how build errors are displayed slightly (#7223)
* Cleanup error formatting a little

* Add error for using import statement with CommonJS-only features

* Update js_ast.zig

* Further tweaks to formatting, also print error.cause

* Add some snapshot tests for errors

* Make these snapshot tests

* Ignore mimalloc warnings

* Update error message parsing in bundling tests

* Increase timeout on the test

* Update expectBundled.ts

* Update test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-20 15:07:13 -08:00

22 lines
625 B
JavaScript

import { test, expect } from "bun:test";
test("error.cause", () => {
const err = new Error("error 1");
const err2 = new Error("error 2", { cause: err });
expect(Bun.inspect(err2).replaceAll(import.meta.dir, "[dir]")).toMatchSnapshot();
});
test("Error", () => {
const err = new Error("my message");
expect(Bun.inspect(err).replaceAll(import.meta.dir, "[dir]")).toMatchSnapshot();
});
test("BuildMessage", async () => {
try {
await import("./inspect-error-fixture-bad.js");
expect.unreachable();
} catch (e) {
expect(Bun.inspect(e).replaceAll(import.meta.dir, "[dir]")).toMatchSnapshot();
}
});