@@ -19,7 +19,7 @@ const variants = vitest.inject('variants');
1919type Fixtures < Addons extends AddonMap > = {
2020 page : Page ;
2121 run ( variant : ProjectVariant , options : OptionMap < Addons > ) : Promise < string > ;
22- cwdVariant : ( variant : ProjectVariant ) => string ;
22+ cwdVariant : ( flavor : string , variant : ProjectVariant ) => string ;
2323} ;
2424
2525const installAddonHelper = async < Addons extends AddonMap > (
@@ -44,7 +44,10 @@ const installAddonHelper = async <Addons extends AddonMap>(
4444
4545export function setupTest < Addons extends AddonMap > (
4646 addons : Addons ,
47- options ?: { skipBrowser ?: boolean ; runPrepareAndInstallWithOption ?: OptionMap < Addons > }
47+ options ?: {
48+ skipBrowser ?: boolean ;
49+ runPrepareAndInstallWithOption ?: Record < string , OptionMap < Addons > > ;
50+ }
4851) {
4952 const test = vitest . test . extend < Fixtures < Addons > > ( { } as any ) ;
5053
@@ -92,8 +95,10 @@ export function setupTest<Addons extends AddonMap>(
9295 if ( options ?. runPrepareAndInstallWithOption ) {
9396 // prepare: run addon for all variants
9497 for ( const variant of variants ) {
95- const cwd = create ( { testId : variant , variant } ) ;
96- await installAddonHelper ( cwd , addons , variant , options . runPrepareAndInstallWithOption ) ;
98+ for ( const [ key , value ] of Object . entries ( options . runPrepareAndInstallWithOption ) ) {
99+ const cwd = create ( { testId : key + '_' + variant , variant } ) ;
100+ await installAddonHelper ( cwd , addons , variant , value ) ;
101+ }
97102 }
98103
99104 // install: run pnpm install
@@ -108,11 +113,11 @@ export function setupTest<Addons extends AddonMap>(
108113 browserCtx = await browser . newContext ( ) ;
109114 ctx . page = await browserCtx . newPage ( ) ;
110115 }
111- ctx . cwdVariant = ( variant ) => {
112- return path . resolve ( cwdTestName , variant ) ;
116+ ctx . cwdVariant = ( flavor , variant ) => {
117+ return path . resolve ( cwdTestName , ` ${ flavor } _ ${ variant } ` ) ;
113118 } ;
114119 ctx . run = async ( variant , runOptions ) => {
115- const cwd = create ( { testId : variant , variant } ) ;
120+ const cwd = create ( { testId : ctx . task . id , variant } ) ;
116121 await installAddonHelper ( cwd , addons , variant , runOptions ) ;
117122 return cwd ;
118123 } ;
0 commit comments