summaryrefslogtreecommitdiff
path: root/cli/tests/unit/console_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/console_test.ts')
-rw-r--r--cli/tests/unit/console_test.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts
index b5dcf2f05..4201a2a46 100644
--- a/cli/tests/unit/console_test.ts
+++ b/cli/tests/unit/console_test.ts
@@ -1823,6 +1823,48 @@ unitTest(function inspectProxy() {
);
});
+unitTest(function inspectError() {
+ const error1 = new Error("This is an error");
+ const error2 = new Error("This is an error", {
+ cause: new Error("This is a cause error"),
+ });
+
+ assertStringIncludes(
+ stripColor(Deno.inspect(error1)),
+ "Error: This is an error",
+ );
+ assertStringIncludes(
+ stripColor(Deno.inspect(error2)),
+ "Error: This is an error",
+ );
+ assertStringIncludes(
+ stripColor(Deno.inspect(error2)),
+ "Caused by Error: This is a cause error",
+ );
+});
+
+unitTest(function inspectErrorCircular() {
+ const error1 = new Error("This is an error");
+ const error2 = new Error("This is an error", {
+ cause: new Error("This is a cause error"),
+ });
+ error1.cause = error1;
+ error2.cause.cause = error2;
+
+ assertStringIncludes(
+ stripColor(Deno.inspect(error1)),
+ "Error: This is an error",
+ );
+ assertStringIncludes(
+ stripColor(Deno.inspect(error2)),
+ "Error: This is an error",
+ );
+ assertStringIncludes(
+ stripColor(Deno.inspect(error2)),
+ "Caused by Error: This is a cause error",
+ );
+});
+
unitTest(function inspectColors() {
assertEquals(Deno.inspect(1), "1");
assertStringIncludes(Deno.inspect(1, { colors: true }), "\x1b[");