File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -407,6 +407,25 @@ export class TestRunner extends vscode.Disposable {
407407 return
408408
409409 const coverage = readCoverageReport ( reportsDirectory )
410+ // TODO: quick patch, coverage shouldn't report negative columns
411+ function ensureLoc ( loc : any ) {
412+ if ( ! loc ) {
413+ return
414+ }
415+ if ( loc . start ?. column && loc . start . column < 0 ) {
416+ loc . start . column = 0
417+ }
418+ if ( loc . end ?. column && loc . end . column < 0 ) {
419+ loc . end . column = 0
420+ }
421+ }
422+ for ( const file in coverage ) {
423+ for ( const key in coverage [ file ] . branchMap ) {
424+ const branch = coverage [ file ] . branchMap [ key ]
425+ ensureLoc ( branch . loc )
426+ branch . locations ?. forEach ( ( loc : any ) => ensureLoc ( loc ) )
427+ }
428+ }
410429 await coverageContext . applyJson ( testRun , coverage )
411430
412431 rm ( reportsDirectory , { recursive : true , force : true } ) . then ( ( ) => {
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export class TestTree extends vscode.Disposable {
2121 // file test items have the project name in their id, so we need a separate map
2222 // to store all of them
2323 private testItemsByFile = new Map < string , vscode . TestItem [ ] > ( )
24+ private testFiles = new Set < string > ( )
2425
2526 private watcher : ExtensionWatcher
2627
@@ -134,7 +135,7 @@ export class TestTree extends vscode.Disposable {
134135 if ( cached )
135136 return cached
136137
137- const fileUri = vscode . Uri . file ( file )
138+ const fileUri = vscode . Uri . file ( resolve ( file ) )
138139 const parentItem = this . getOrCreateFolderTestItem ( api , dirname ( file ) )
139140 const label = `${ basename ( file ) } ${ project ? ` [${ project } ]` : '' } `
140141 const testFileItem = this . controller . createTestItem (
@@ -159,10 +160,11 @@ export class TestTree extends vscode.Disposable {
159160 const cachedItems = this . testItemsByFile . get ( normalizedFile ) || [ ]
160161 cachedItems . push ( testFileItem )
161162 this . testItemsByFile . set ( normalizedFile , cachedItems )
163+ this . testFiles . add ( fileUri . fsPath )
162164 vscode . commands . executeCommand (
163165 'setContext' ,
164166 'vitest.testFiles' ,
165- Array . from ( this . testItemsByFile . keys ( ) ) ,
167+ Array . from ( this . testFiles ) ,
166168 )
167169
168170 return testFileItem
You can’t perform that action at this time.
0 commit comments