summaryrefslogtreecommitdiff
path: root/runtime/js/40_testing.js
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2022-05-05 00:15:54 +0100
committerGitHub <noreply@github.com>2022-05-05 01:15:54 +0200
commitca134d25e1c281384a1a131c19d0574e7c8d30e8 (patch)
tree90ffc4b39fc131f50eebab74c53c5b2b64eba32f /runtime/js/40_testing.js
parent6a21fe745acf44fb32c294a34314abf58cc43c30 (diff)
feat(test): Show Deno.test() call locations for failures (#14484)
Diffstat (limited to 'runtime/js/40_testing.js')
-rw-r--r--runtime/js/40_testing.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js
index b176e7b2d..47af45110 100644
--- a/runtime/js/40_testing.js
+++ b/runtime/js/40_testing.js
@@ -635,6 +635,16 @@
);
}
+ const jsError = Deno.core.destructureError(new Error());
+ // Note: There might pop up a case where one of the filename, line number or
+ // column number from the caller isn't defined. We assume never for now.
+ // Make `TestDescription::location` optional if such a case is found.
+ testDef.location = {
+ fileName: jsError.frames[1].fileName,
+ lineNumber: jsError.frames[1].lineNumber,
+ columnNumber: jsError.frames[1].columnNumber,
+ };
+
ArrayPrototypePush(tests, testDef);
}
@@ -1097,6 +1107,7 @@
const description = {
origin,
name: test.name,
+ location: test.location,
};
const earlier = DateNow();