@@ -103,20 +103,47 @@ async function runPackagedRender(
103103 outputPath : string ,
104104) : Promise < void > {
105105 const launchPath = getLaunchPath ( workingDir ) ;
106- const launchArgs =
106+ const commonOptions = {
107+ cwd : path . dirname ( launchPath ) ,
108+ stdio : 'inherit' as const ,
109+ timeout : 240000 ,
110+ } ;
111+ const linuxLaunchArgs =
107112 process . platform === 'linux'
108- ? [ '--no-sandbox' , '--disable-setuid-sandbox' ]
113+ ? [
114+ '--no-sandbox' ,
115+ '--disable-setuid-sandbox' ,
116+ '--headless' ,
117+ '--disable-gpu' ,
118+ '--ozone-platform=headless' ,
119+ '--ozone-platform-hint=headless' ,
120+ ]
109121 : [ ] ;
122+ const launchArgs = [
123+ ...linuxLaunchArgs ,
124+ '--integration-render-test' ,
125+ outputPath ,
126+ ] ;
127+
128+ if (
129+ process . platform === 'linux' &&
130+ ! process . env . DISPLAY &&
131+ ! process . env . WAYLAND_DISPLAY
132+ ) {
133+ try {
134+ await execa ( 'xvfb-run' , [ '-a' , launchPath , ...launchArgs ] , commonOptions ) ;
135+ return ;
136+ } catch ( error ) {
137+ const execaError = error as { code ?: string } ;
138+ if ( execaError . code !== 'ENOENT' ) {
139+ throw error ;
140+ }
141+ // `xvfb-run` may not be present in all environments.
142+ // Fall back to direct headless launch flags.
143+ }
144+ }
110145
111- await execa (
112- launchPath ,
113- [ ...launchArgs , '--integration-render-test' , outputPath ] ,
114- {
115- cwd : path . dirname ( launchPath ) ,
116- stdio : 'inherit' ,
117- timeout : 240000 ,
118- } ,
119- ) ;
146+ await execa ( launchPath , launchArgs , commonOptions ) ;
120147}
121148
122149test ( 'Electron template should package and render after publish-style dependency rewriting' , async ( ) => {
0 commit comments