@@ -38,6 +38,7 @@ import { getHooks, setFn, setHooks, setTestFixture } from './map'
3838import { getCurrentTest } from './test-state'
3939import { findTestFileStackTrace } from './utils'
4040import { createChainable } from './utils/chain'
41+ import { createTaskName } from './utils/tasks'
4142
4243/**
4344 * Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
@@ -213,14 +214,15 @@ function createDefaultSuite(runner: VitestRunner) {
213214}
214215
215216export function clearCollectorContext (
216- filepath : string ,
217+ file : File ,
217218 currentRunner : VitestRunner ,
218219) : void {
219220 if ( ! defaultSuite ) {
220221 defaultSuite = createDefaultSuite ( currentRunner )
221222 }
223+ defaultSuite . file = file
222224 runner = currentRunner
223- currentTestFilepath = filepath
225+ currentTestFilepath = file . filepath
224226 collectorContext . tasks . length = 0
225227 defaultSuite . clear ( )
226228 collectorContext . currentSuite = defaultSuite
@@ -297,10 +299,16 @@ function createSuiteCollector(
297299
298300 const task = function ( name = '' , options : TaskCustomOptions = { } ) {
299301 const timeout = options ?. timeout ?? runner . config . testTimeout
302+ const currentSuite = collectorContext . currentSuite ?. suite
300303 const task : Test = {
301304 id : '' ,
302305 name,
303- suite : collectorContext . currentSuite ?. suite ,
306+ fullName : createTaskName ( [
307+ currentSuite ?. fullName ?? collectorContext . currentSuite ?. file ?. fullName ,
308+ name ,
309+ ] ) ,
310+ fullTestName : createTaskName ( [ currentSuite ?. fullTestName , name ] ) ,
311+ suite : currentSuite ,
304312 each : options . each ,
305313 fails : options . fails ,
306314 context : undefined ! ,
@@ -439,11 +447,18 @@ function createSuiteCollector(
439447 suiteOptions = { timeout : suiteOptions }
440448 }
441449
450+ const currentSuite = collectorContext . currentSuite ?. suite
451+
442452 suite = {
443453 id : '' ,
444454 type : 'suite' ,
445455 name,
446- suite : collectorContext . currentSuite ?. suite ,
456+ fullName : createTaskName ( [
457+ currentSuite ?. fullName ?? collectorContext . currentSuite ?. file ?. fullName ,
458+ name ,
459+ ] ) ,
460+ fullTestName : createTaskName ( [ currentSuite ?. fullTestName , name ] ) ,
461+ suite : currentSuite ,
447462 mode,
448463 each,
449464 file : undefined ! ,
0 commit comments