Skip to content

[Bug]: Stack trace location regex matches wrong path #225

@f0x52

Description

@f0x52

Checklist

Actual behavior

Happened to get unlucky with the stacktrace on a Mocha test, where the cut-off assertion error in the stacktrace ended with (..., which resulted in the error TestMessage trying to open a file that doesn't exist

AssertionError [ERR_ASSERTION]:
<lines removed>
requestAnimationFrame(...
    at Context.<anonymous> (tests/render-to-stream.spec.tsx:59:10)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)"

the locationRe regex matches (...\n at Context.<anonymous> (tests/render-to-stream.spec.tsx:59:10) and so it tries to open the filepath "file://<redacted>/...%0A%20%20%20%20at%20Context.%3Canonymous%3E%20%28tests/render-to-stream.spec.tsx"

Expected behavior

To only match the last part of the stacktrace, opening tests/render-to-stream.spec.tsx and showing the error in the correct location

Minimal, Reproducible Example

	it('should give an error', function () {
		throw new Error("(...");
	});

Output

[error] Error: Test process exited with code 1 (as expected with a failing test)

Plugin Version Details

Built from latest git commit 0108cbf

VS Code Version Details

Further details

Do stacktrace paths ever include newlines? Changing the regex to
const locationRe = /\(([^\n):]+?):([0-9]+):([0-9]+)\)[ \t]*\r?\n?/g; seems to work for me

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions