@@ -10,6 +10,7 @@ import { registrySetup } from './registrySetup';
1010
1111interface SentryTestVariant {
1212 'build-command' : string ;
13+ 'assert-command' ?: string ;
1314 label : string ;
1415}
1516
@@ -80,7 +81,7 @@ async function getVariantBuildCommand(
8081 packageJsonPath : string ,
8182 variantLabel : string ,
8283 testAppPath : string ,
83- ) : Promise < { buildCommand : string ; testLabel : string ; matchedVariantLabel ?: string } > {
84+ ) : Promise < { buildCommand : string ; assertCommand : string ; testLabel : string ; matchedVariantLabel ?: string } > {
8485 try {
8586 const packageJsonContent = await readFile ( packageJsonPath , 'utf-8' ) ;
8687 const packageJson : PackageJson = JSON . parse ( packageJsonContent ) ;
@@ -95,18 +96,22 @@ async function getVariantBuildCommand(
9596 if ( matchingVariant ) {
9697 return {
9798 buildCommand : `volta run ${ matchingVariant [ 'build-command' ] } ` ,
99+ assertCommand : matchingVariant [ 'assert-command' ]
100+ ? `volta run ${ matchingVariant [ 'assert-command' ] } `
101+ : 'volta run pnpm test:assert' ,
98102 testLabel : matchingVariant . label ,
99103 matchedVariantLabel : matchingVariant . label ,
100104 } ;
101105 }
102106
103107 console . log ( `No matching variant found for "${ variantLabel } " in ${ testAppPath } , using default build` ) ;
104- } catch ( error ) {
108+ } catch {
105109 console . log ( `Could not read variants from package.json for ${ testAppPath } , using default build` ) ;
106110 }
107111
108112 return {
109113 buildCommand : 'volta run pnpm test:build' ,
114+ assertCommand : 'volta run pnpm test:assert' ,
110115 testLabel : testAppPath ,
111116 } ;
112117}
@@ -190,9 +195,13 @@ async function run(): Promise<void> {
190195 await copyToTemp ( originalPath , tmpDirPath ) ;
191196 const cwd = tmpDirPath ;
192197 // Resolve variant if needed
193- const { buildCommand, testLabel, matchedVariantLabel } = variantLabel
198+ const { buildCommand, assertCommand , testLabel, matchedVariantLabel } = variantLabel
194199 ? await getVariantBuildCommand ( join ( tmpDirPath , 'package.json' ) , variantLabel , testAppPath )
195- : { buildCommand : 'volta run pnpm test:build' , testLabel : testAppPath } ;
200+ : {
201+ buildCommand : 'volta run pnpm test:build' ,
202+ assertCommand : 'volta run pnpm test:assert' ,
203+ testLabel : testAppPath ,
204+ } ;
196205
197206 // Print which variant we're using if found
198207 if ( matchedVariantLabel ) {
@@ -203,9 +212,11 @@ async function run(): Promise<void> {
203212 await asyncExec ( buildCommand , { env, cwd } ) ;
204213
205214 console . log ( `Testing ${ testLabel } ...` ) ;
206- // Pass command and arguments as an array to prevent command injection
207- const testCommand = [ 'volta' , 'run' , 'pnpm' , 'test:assert' , ...testFlags ] ;
208- await asyncExec ( testCommand , { env, cwd } ) ;
215+ // Use the variant's assert command if available, otherwise use default
216+ // Construct the full command as a string to handle environment variables (e.g., NODE_VERSION=20)
217+ // and append test flags
218+ const fullAssertCommand = testFlags . length > 0 ? `${ assertCommand } ${ testFlags . join ( ' ' ) } ` : assertCommand ;
219+ await asyncExec ( fullAssertCommand , { env, cwd } ) ;
209220
210221 // clean up (although this is tmp, still nice to do)
211222 await rm ( tmpDirPath , { recursive : true } ) ;
0 commit comments