diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-08-02 17:11:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 17:11:04 +0200 |
commit | d9c85e016f054fd3b6c68a54213e7c0ad8c3a8f4 (patch) | |
tree | edc896aceafb0c35ddedea2ba28cc7ce600bf6e7 /cli/js | |
parent | 1cb16683bcaf3223de560a7560647aadfea78d31 (diff) |
fix(node): node:test reports correct location (#20025)
Also removed some noisy output that caused test flakiness.
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/40_testing.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index 8b1557fbf..d119552e4 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -677,11 +677,21 @@ function test( // Delete this prop in case the user passed it. It's used to detect steps. delete testDesc.parent; const jsError = core.destructureError(new Error()); - testDesc.location = { - fileName: jsError.frames[1].fileName, - lineNumber: jsError.frames[1].lineNumber, - columnNumber: jsError.frames[1].columnNumber, - }; + let location; + + for (let i = 0; i < jsError.frames.length; i++) { + const filename = jsError.frames[i].fileName; + if (filename.startsWith("ext:") || filename.startsWith("node:")) { + continue; + } + location = { + fileName: jsError.frames[i].fileName, + lineNumber: jsError.frames[i].lineNumber, + columnNumber: jsError.frames[i].columnNumber, + }; + break; + } + testDesc.location = location; testDesc.fn = wrapTest(testDesc); const { id, origin } = ops.op_register_test(testDesc); |