From 52b3b4cd413c74d459aa298e2a9b89d88d14c4ae Mon Sep 17 00:00:00 2001 From: ItsSim Date: Sun, 1 Sep 2024 08:00:46 +0200 Subject: [PATCH] test: more logging for beforeEach --- app/tests/e2e/util/setup-test.js | 65 +++++++++++++++++--------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/app/tests/e2e/util/setup-test.js b/app/tests/e2e/util/setup-test.js index 792292d..3760a02 100644 --- a/app/tests/e2e/util/setup-test.js +++ b/app/tests/e2e/util/setup-test.js @@ -52,36 +52,41 @@ module.exports = () => { } ); test.beforeEach( async () => { - console.info( '[beforeEach] starting beforeEach' ); - // Reset console errors at the start of each test - logs = []; - - // Pass in --test-mode for headless testing - electronApp = await electron.launch( { - timeout: 60000, - cwd: exeDir, - args: [ appInfo.main, '--disable-http-cache', '--fl-test-mode' ], - executablePath: appInfo.executable // Path to the Electron executable - } ); - console.info( '[beforeEach] launched electronApp' ); - - await electronApp.evaluate( async ( { session } ) => await session.defaultSession.clearCache() ); - - // Log main process - electronApp.process().stdout.on( 'data', data => console.info( `[main] ${data}` ) ); - electronApp.process().stderr.on( 'data', error => console.info( `[main] ${error}` ) ); - electronApp.process().stderr.on( 'data', error => logs.push( `[main] ${error}` ) ); - - page = await electronApp.firstWindow(); - console.info( '[beforeEach] waited for firstWindow' ); - - // Log renderer process - page.on( 'console', log => console.info( `[renderer] ${log.text()}` ) ); - page.on( 'console', log => { - if ( log.type() === 'error' ) { - logs.push( `[renderer] ${log.text()}` ); - } - } ); + try { + console.info( '[beforeEach] starting beforeEach' ); + // Reset console errors at the start of each test + logs = []; + + // Pass in --test-mode for headless testing + electronApp = await electron.launch( { + timeout: 120000, + cwd: exeDir, + args: [ appInfo.main, '--disable-http-cache', '--fl-test-mode' ], + executablePath: appInfo.executable // Path to the Electron executable + } ); + console.info( '[beforeEach] launched electronApp' ); + + await electronApp.evaluate( async ( { session } ) => await session.defaultSession.clearCache() ); + + // Log main process + electronApp.process().stdout.on( 'data', data => console.info( `[main] ${data}` ) ); + electronApp.process().stderr.on( 'data', error => console.info( `[main] ${error}` ) ); + electronApp.process().stderr.on( 'data', error => logs.push( `[main] ${error}` ) ); + + page = await electronApp.firstWindow(); + console.info( '[beforeEach] waited for firstWindow' ); + + // Log renderer process + page.on( 'console', log => console.info( `[renderer] ${log.text()}` ) ); + page.on( 'console', log => { + if ( log.type() === 'error' ) { + logs.push( `[renderer] ${log.text()}` ); + } + } ); + } catch ( error ) { + console.error( '[beforeEach] failed to launch electronApp:', error ); + throw error; + } } ); test.afterEach( async () => {