@@ -320,40 +320,53 @@ async function runTestem({ suite, port, launch, dev, processOptions, context } =
320320 * @returns {Promise<boolean | undefined> } true if some tests failed
321321 */
322322async function test ( suite , tests , options = { } ) {
323- const processOptions = {
324- cwd : wd ,
325- env : {
326- ...process . env ,
327- TEST_FILES : ( tests || [ ] ) . join ( ',' ) ,
328- NODE_CMD : [ 'qunit' , 'test/node_test_setup.js' , 'test/lib' ] . concat ( tests || `test/${ suite } ` ) . join ( ' ' ) ,
329- VERBOSE : Number ( options . verbose ) ,
330- QUNIT_DEBUG_VISUAL_TESTS : Number ( options . debug ) ,
331- QUNIT_RECREATE_VISUAL_REFS : Number ( options . recreate ) ,
332- QUNIT_FILTER : options . filter ,
333- REPORT_FILE : options . out
334- } ,
335- shell : true ,
336- stdio : 'inherit' ,
337- }
338-
339323 let failed = false ;
324+ const qunitEnv = {
325+ QUNIT_DEBUG_VISUAL_TESTS : Number ( options . debug ) ,
326+ QUNIT_RECREATE_VISUAL_REFS : Number ( options . recreate ) ,
327+ QUNIT_FILTER : options . filter ,
328+ } ;
329+ const env = {
330+ ...process . env ,
331+ TEST_FILES : ( tests || [ ] ) . join ( ',' ) ,
332+ NODE_CMD : [ 'qunit' , 'test/node_test_setup.js' , 'test/lib' ] . concat ( tests || `test/${ suite } ` ) . join ( ' ' ) ,
333+ VERBOSE : Number ( options . verbose ) ,
334+ REPORT_FILE : options . out
335+ } ;
336+ const browserContexts = options . context . filter ( c => c !== 'node' ) ;
340337
341338 // temporary revert
342339 // run node tests directly with qunit
343340 if ( options . context . includes ( 'node' ) ) {
344341 try {
345- cp . execSync ( processOptions . env . NODE_CMD , processOptions ) ;
342+ cp . execSync ( env . NODE_CMD , {
343+ cwd : wd ,
344+ env : {
345+ ...env ,
346+ // browser takes precendence in golden ref generation
347+ ...( browserContexts . length === 0 ? qunitEnv : { } )
348+ } ,
349+ shell : true ,
350+ stdio : 'inherit' ,
351+ } ) ;
346352 } catch ( error ) {
347353 failed = true ;
348354 }
349355 }
350356
351- const browserContexts = options . context . filter ( c => c !== 'node' ) ;
352357 if ( browserContexts . length > 0 ) {
353358 failed = await runTestem ( {
354359 ...options ,
355360 suite,
356- processOptions,
361+ processOptions : {
362+ cwd : wd ,
363+ env : {
364+ ...env ,
365+ ...qunitEnv
366+ } ,
367+ shell : true ,
368+ stdio : 'inherit' ,
369+ } ,
357370 context : browserContexts
358371 } ) || failed ;
359372 }
0 commit comments