Skip to content

Commit

Permalink
chore(ci): log electron app messages (#6317)
Browse files Browse the repository at this point in the history
Logging electron app log
  • Loading branch information
kraenhansen authored Oct 4, 2024
1 parent 946a60c commit eb86f23
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/compass-e2e-tests/helpers/compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ export const serverSatisfies = (
);
};

// For the user data dirs
let i = 0;
// For the user data dirs and logs
let runCounter = 0;

interface Coverage {
main?: string;
Expand Down Expand Up @@ -569,7 +569,7 @@ async function processCommonOpts({
if (!defaultUserDataDir) {
defaultUserDataDir = path.join(
os.tmpdir(),
`user-data-dir-${Date.now().toString(32)}-${++i}`
`user-data-dir-${Date.now().toString(32)}-${runCounter}`
);
}
const chromedriverLogPath = path.join(
Expand Down Expand Up @@ -630,6 +630,7 @@ async function startCompassElectron(
name: string,
opts: StartCompassOptions = {}
): Promise<Compass> {
runCounter++;
const { testPackagedApp, binary } = await getCompassExecutionParameters();

const { needsCloseWelcomeModal, webdriverOptions, wdioOptions, chromeArgs } =
Expand All @@ -644,6 +645,15 @@ async function startCompassElectron(
chromeArgs.push('--showed-network-opt-in=true');
}

// Logging output from Electron, even before the app loads any JavaScript
const electronLogFile = path.join(LOG_PATH, `electron-${runCounter}.log`);
chromeArgs.push(
// See https://www.electronjs.org/docs/latest/api/command-line-switches#--enable-loggingfile
'--enable-logging=file',
// See https://www.electronjs.org/docs/latest/api/command-line-switches#--log-filepath
`--log-file=${electronLogFile}`
);

if (opts.extraSpawnArgs) {
chromeArgs.push(...opts.extraSpawnArgs);
}
Expand Down Expand Up @@ -756,6 +766,7 @@ export async function startBrowser(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
opts: StartCompassOptions = {}
) {
runCounter++;
const { webdriverOptions, wdioOptions } = await processCommonOpts();

const browser: CompassBrowser = (await remote({
Expand Down

0 comments on commit eb86f23

Please sign in to comment.