From ca134d25e1c281384a1a131c19d0574e7c8d30e8 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Thu, 5 May 2022 00:15:54 +0100 Subject: feat(test): Show Deno.test() call locations for failures (#14484) --- runtime/js/40_testing.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'runtime/js') 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(); -- cgit v1.2.3