diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-05-29 13:02:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-29 14:02:36 +0200 |
commit | 49c70774012e929b3c77b808edc5a7908bcb6fa2 (patch) | |
tree | 40bc92223baab70b46bdf4f7a2f5d5edf7592308 /cli/tests | |
parent | ce246d8d85283af16250dcb5970eca6caf9cca6d (diff) |
fix(cli/js/error_stack): Expose Error.captureStackTrace (#5254)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/error_stack_test.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cli/tests/unit/error_stack_test.ts b/cli/tests/unit/error_stack_test.ts index eb0a5c0e6..052cb9591 100644 --- a/cli/tests/unit/error_stack_test.ts +++ b/cli/tests/unit/error_stack_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { unitTest, assert } from "./test_util.ts"; +import { assert, assertEquals, unitTest } from "./test_util.ts"; // @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol const { setPrepareStackTrace } = Deno[Deno.internal]; @@ -96,6 +96,18 @@ unitTest(function prepareStackTrace(): void { assert(result.includes(".ts:"), "should remap to something in 'js/'"); }); +unitTest(function captureStackTrace(): void { + function foo(): void { + const error = new Error(); + const stack1 = error.stack!; + Error.captureStackTrace(error, foo); + const stack2 = error.stack!; + // stack2 should be stack1 without the first frame. + assertEquals(stack2, stack1.replace(/(?<=^[^\n]*\n)[^\n]*\n/, "")); + } + foo(); +}); + unitTest(function applySourceMap(): void { const result = Deno.applySourceMap({ fileName: "CLI_SNAPSHOT.js", |