Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ const forEachLeaf = (test: vscode.TestItem, fn: (test: vscode.TestItem) => void)

const escapeRe = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const forceCRLF = (str: string) => str.replace(/(?<!\r)\n/gm, '\r\n');
const locationRe = /\(([^):]+?):([0-9]+):([0-9]+)\)[ \t]*\r?\n?/g;
const locationRe = /\(([^\r\n):]+?):([0-9]+):([0-9]+)\)[ \t]*\r?\n?/g;

/**
* Replaces all stack frames in the stack with source-mapped equivalents.
Expand Down
47 changes: 47 additions & 0 deletions src/test/integration/simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('simple', () => {
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
['stacktrace.test.js', [['stacktrace', [['should parse error location correctly']]]]],
]);
});

Expand All @@ -58,6 +59,7 @@ describe('simple', () => {
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
['stacktrace.test.js', [['stacktrace', [['should parse error location correctly']]]]],
]);
});

Expand All @@ -78,6 +80,7 @@ describe('simple', () => {
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
['stacktrace.test.js', [['stacktrace', [['should parse error location correctly']]]]],
]);
});

Expand Down Expand Up @@ -106,6 +109,8 @@ describe('simple', () => {
['skip-suite-2', [['addition'], ['subtraction']]],
],
],

['stacktrace.test.js', [['stacktrace', [['should parse error location correctly']]]]],
]);
});

Expand Down Expand Up @@ -133,6 +138,11 @@ describe('simple', () => {
'skip.test.js/skip-suite-1/subtraction': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-2/addition': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-2/subtraction': ['enqueued', 'started', 'passed'],
'stacktrace.test.js/stacktrace/should parse error location correctly': [
'enqueued',
'started',
'failed',
],
});
});

Expand Down Expand Up @@ -246,6 +256,11 @@ describe('simple', () => {
'skip.test.js/skip-suite-1/subtraction': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-2/addition': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-2/subtraction': ['enqueued', 'started', 'passed'],
'stacktrace.test.js/stacktrace/should parse error location correctly': [
'enqueued',
'started',
'failed',
],
});
});

Expand Down Expand Up @@ -275,6 +290,38 @@ describe('simple', () => {
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
['stacktrace.test.js', [['stacktrace', [['should parse error location correctly']]]]],
]);
});

it('parses error stacktrace correctly', async () => {
const c = await getController();
const profiles = c.profiles;
expect(profiles).to.have.lengthOf(2);

const item = c.ctrl.items.get('stacktrace.test.js')!;
const run = await captureTestRun(
c,
new vscode.TestRunRequest(
[item],
undefined,
profiles.find((p) => p.kind === vscode.TestRunProfileKind.Run),
),
);

run.expectStates({
'stacktrace.test.js/stacktrace/should parse error location correctly': [
'enqueued',
'started',
'failed',
],
});

const failed = run.states.find((s) => s.state === 'failed');
expect(failed!.message!.location!.range.start.line).to.equal(4);
expect(failed!.message!.location!.range.start.character).to.equal(11);
expect(failed!.message!.location!.range.end.line).to.equal(4);
expect(failed!.message!.location!.range.end.character).to.equal(11);
expect(failed!.message!.location!.uri.fsPath).to.equal(item.uri!.fsPath);
});
});
7 changes: 7 additions & 0 deletions test-workspaces/simple/stacktrace.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
describe('stacktrace', () => {
it('should parse error location correctly', function () {
console.log('before');
throw new Error('(...');
console.log('after');
});
});
Loading