Skip to content

Commit e790a36

Browse files
committed
fix: report failing location as first non-internal position
1 parent 212e77a commit e790a36

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class TestRunner {
124124
actual !== undefined && expected !== undefined
125125
? vscode.TestMessage.diff(asText, expected, actual)
126126
: new vscode.TestMessage(asText);
127-
const lastFrame = stack?.[0];
127+
const lastFrame = stack?.find((s) => !s.file?.startsWith("node:"));
128128
const location = lastFrame?.file
129129
? mapLocation(lastFrame.file, lastFrame.lineNumber, lastFrame.column)
130130
: undefined;

testCases/simple/runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ it("runs tests", async () => {
9696
"test/inAFolder.js/addition": ["started", "passed"],
9797
"test-WithADash.js/addition": ["started", "passed"],
9898
"test.js/addition": ["started", "passed"],
99-
"withADashTheOtherWay-test.js/addition": ["started", "passed"],
99+
"withADashTheOtherWay-test.js/addition": ["started", "failed"],
100100
"hello.test.js/math/addition": ["started", "passed"],
101101
"hello.test.js/math/subtraction": ["started", "passed"],
102102
"otherFolder/some.test.js/addition": ["started", "passed"],
@@ -194,7 +194,7 @@ it("handles file and directory excludes", async () => {
194194
"otherFolder/some.test.js/addition": ["started", "passed"],
195195
"test-WithADash.js/addition": ["started", "passed"],
196196
"test.js/addition": ["started", "passed"],
197-
"withADashTheOtherWay-test.js/addition": ["started", "passed"],
197+
"withADashTheOtherWay-test.js/addition": ["started", "failed"],
198198
"withADot.test.js/addition": ["started", "passed"],
199199
});
200200
});

testCases/simple/workspace/withADashTheOtherWay-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ const { test } = require("node:test");
22
const { strictEqual } = require("node:assert");
33

44
test("addition", () => {
5-
require('node:fs').readFileSync('does not exist');
5+
require("node:fs").readFileSync("does not exist"); // #2
66
});

0 commit comments

Comments
 (0)