mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
fix(cli/js/error_stack): Expose Error.captureStackTrace (#5254)
This commit is contained in:
parent
ce246d8d85
commit
49c7077401
4 changed files with 56 additions and 41 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue