Skip to content

Commit

Permalink
fix: don't panic when switching test view
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Apr 17, 2024
1 parent b646158 commit 7ce92f1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/testTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ export class TestTree extends vscode.Disposable {
)
testFileItem.tags = [api.tag]
testFileItem.canResolveChildren = true
parentItem.children.add(testFileItem)
this.fileItems.set(fileId, testFileItem)
const cachedItems = this.testItemsByFile.get(normalizedFile) || []
cachedItems.push(testFileItem)
this.testItemsByFile.set(normalizedFile, cachedItems)
TestFile.register(
testFileItem,
normalizedFile,
api,
project,
)
parentItem.children.add(testFileItem)
this.fileItems.set(fileId, testFileItem)
const cachedItems = this.testItemsByFile.get(normalizedFile) || []
cachedItems.push(testFileItem)
this.testItemsByFile.set(normalizedFile, cachedItems)

return testFileItem
}
Expand Down Expand Up @@ -269,13 +269,14 @@ export class TestTree extends vscode.Disposable {
const position = new vscode.Position(location.line - 1, location.column)
testItem.range = new vscode.Range(position, position)
}
this.flatTestItems.set(task.id, testItem)
item.children.add(testItem)
if (task.type === 'suite')
TestSuite.register(testItem, fileData)
else if (task.type === 'test' || task.type === 'custom')
TestCase.register(testItem, fileData)

this.flatTestItems.set(task.id, testItem)
item.children.add(testItem)

if (task.result?.errors) {
const error = task.result.errors.map(error => error.stack).join('\n')
testItem.error = error
Expand Down

0 comments on commit 7ce92f1

Please sign in to comment.