Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: map test failure to correct line with latest Vitest #111

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/watch.ts
Expand Up @@ -279,23 +279,36 @@ export class TestWatcher extends Disposable {
}
}

function getSourceFilepathAndLocationFromStack(stack: ParsedStack): { sourceFilepath?: string; line: number; column: number } {
if (stack.sourcePos) {
return {
sourceFilepath: stack.sourcePos.source?.replace(/\//g, path.sep),
line: stack.sourcePos.line,
column: stack.sourcePos.column,
}
}

return {
sourceFilepath: stack.file.replace(/\//g, path.sep),
line: stack.line,
column: stack.column,
}
}

function parseLocationFromStacks(testItem: TestItem, stacks: ParsedStack[]): DebuggerLocation | undefined {
if (stacks.length === 0)
return undefined

const targetFilepath = testItem.uri!.fsPath
for (const { sourcePos } of stacks) {
if (!sourcePos)
continue

const sourceFilepath = sourcePos.source?.replace(/\//g, path.sep)
if (sourceFilepath !== targetFilepath || isNaN(sourcePos.column) || isNaN(sourcePos.line))
for (const stack of stacks) {
const { sourceFilepath, line, column } = getSourceFilepathAndLocationFromStack(stack)
if (sourceFilepath !== targetFilepath || isNaN(column) || isNaN(line))
continue

return {
path: sourceFilepath,
line: sourcePos.line,
column: sourcePos.column,
line,
column,
}
}
}
Expand Down