Electron Testing, Monitoring, and Release

Establish basic testing, logging, crash investigation, and pre-release checks for an Electron app.

🎯 Introduction

Once a desktop app is released, problems can arise across operating systems, window states, and file permissions. This article introduces checks that even small projects can use, without adding a complex testing platform.


🧪 Test the most important paths first

Prioritize the workflows users rely on:

  • The app starts and displays its main window.
  • Canceling file selection does not produce a page error.
  • The main process returns an error for invalid IPC arguments.
  • The page provides feedback when reading a file fails.
  • An exported PDF exists and can be opened.

Focus on success and failure paths rather than testing every line of code.


🔍 Diagnose problems with logs

Logs should include at least an event name and the necessary context:

electron/main.js
console.info('[file:open] start');

try {
    const file = await openFile();
    console.info('[file:open] success', { name: file.name });
} catch (error) {
    console.error('[file:open] failed', error);
}

Do not log passwords, tokens, or entire file contents. Production projects can save logs to app.getPath('logs') and limit their size or retention period.

Electron also provides basic crash reporting support. Start by keeping crash reports locally:

electron/main.js
const { crashReporter } = require('electron/main');

crashReporter.start({
    uploadToServer: false,
});

uploadToServer: false is intended here for local learning and inspection. In production, decide whether to upload crash reports based on privacy requirements and your reporting service, and disclose what you collect in advance.


🧰 Pre-release checks

[ ] Resources load in both development and the packaged app
[ ] Startup has been checked on the target Windows, macOS, or Linux system
[ ] File selection, cancellation, and read failures have been tested
[ ] The app icon, name, and version are correct
[ ] Signing or notarization meets release requirements
[ ] A failed update leaves the previous version intact
[ ] Logs contain no sensitive information

Navigation on GitHub, CI platforms, and system signing pages can change. Follow the platform's current interface and official documentation when performing these steps.

Installation permissions, path formats, and signing requirements differ across operating systems. Successfully launching on your development machine alone does not mean the app is ready to ship.

🧾 Summary

  • Prioritize critical success and failure paths in tests.
  • Log events and context without exposing sensitive information.
  • Check resource paths and system permissions again after packaging.
  • Validate signing, installation, and automatic updates on the target platform.
  • A pre-release checklist helps prevent omissions.

❓ Questions and answers

Q1: Why can an installer fail when development works?

Development has a Vite server and the full project directory. Resource paths and permissions differ in a packaged app.

Q2: Are more detailed logs always better?

No. Logs should help diagnose problems while excluding passwords, tokens, and large amounts of user data.

🧪 Practice

Add an error log for a file read failure without including the file contents:

catch (error) {
    // Write your code here
}

🎉 You now have a release-checking approach suitable for a small Electron app.