How to test an Electron application, not just its web interface
Updated:
An Electron application uses web technologies, but users launch it as a desktop program. A standard web page test may therefore verify a form or navigation, but it may not cover application startup, multiple windows, local files or updates. A reliable solution combines checks of the web and desktop layers.
The problem: testing in a browser alone is not enough
Electron has a renderer process for the user interface and a main process that manages windows and desktop functionality. If a test opens only a web address, it bypasses some of the code that customers use in the installed application.
Common problems occur in the following areas:
- the application fails to start after installation or loads the wrong configuration,
- the main and secondary windows do not share state correctly,
- opening a file, exporting or using a custom URL protocol works only in certain environments,
- the application fails to start with the original data after an update,
- an offline state or service outage leaves the interface without a clear response,
- a system dialog, menu or system tray icon behaves differently from the HTML part.
Not every Electron application uses all of these features. The test scope should be based on what your product actually does.
How to divide testing into layers
We verify web components and business logic with faster tests that do not launch the entire application. A smaller number of end-to-end scenarios then launch the packaged Electron application and check the user’s journey from startup to the result.
Playwright provides an interface for launching an Electron application and working with its windows and code in the main process. This support is still marked as experimental in the official documentation, so before a broader implementation, we verify compatibility with the specific Electron version and the way the application is built.
For system dialogs, we choose one of two approaches:
- for a logic test, we replace the dialog in a controlled way and return a known file path,
- for a genuine end-to-end scenario, we add a tool for controlling the native Windows interface.
Playwright does not intercept calls to Electron’s native dialogs because the main process sends them directly to the operating system. We therefore treat the installer, update and data migration as a separate layer. Testing installation and updates describes the process in more detail.
We record video, screenshots, logs and traces as needed in the test configuration. They are not an automatic output of every run, and when sensitive data is involved, you need to determine what may be stored.
What to watch out for
An update test needs a controlled package source, clearly defined original and target versions, and safe test data. File system tests need an isolated working directory so that one run does not affect the next. At the same time, the CI runner must be able to launch a graphical application in a supported environment.
Check the build your customer will receive
Launching the source project and launching the installed program are two different tests. The development version may have files, variables or tools that are missing from the final package. Record the application version, operating system, architecture, executable path and configuration in your pilot. Test startup without the development server and access to the required resources after installation.
Electron’s official automated testing guide also demonstrates launching a development application. That result alone does not verify the distributed package. Playwright lets you specify an executable, but its connection also depends on the program’s settings. Its documentation identifies a launch limitation when the nodeCliInspect fuse, a build switch for debugging arguments, is disabled.
If automation requires a modified test build, record how it differs from the release version. Do not change the production package’s security settings simply to connect a tool. Check critical behaviour in the final package through another suitable approach, such as controlling the operating system’s interface.
An illustrative scenario: open, edit, save and reload
Consider an editor that opens a local document. The test has its own directory and a file containing two known items. Divide the checks as follows:
| Step | What the test should verify |
|---|---|
| Open the document | Both items appear in the correct order with the expected values. |
| Change one item | The selected value changes and the other remains intact. |
| Save under a new name | The new file contains the edited data and the original file remains unchanged. |
| Shut down normally and restart | The application opens the saved file and displays the edited values. |
Compare the result with known expected content, rather than relying only on a “Saved” message. If the format can safely be read outside the application, inspect the created file as well. This distinguishes a confirmation in the interface from an actual write.
Add checks for cancelling the dialog, unsupported input and saving to a directory without the required permission. Agree on the expected response: cancellation should not create a new file, a write error should not appear successful, and the original document must remain available. These are examples of specific acceptance conditions, rather than universal rules for every editor.
Windows and communication between processes
The first window may be a splash screen. The test should find the window with the required function and wait for it to be ready, rather than wait a fixed amount of time. In an editor with multiple windows, also check that changing one document does not overwrite another and that closing an auxiliary window does not unintentionally quit the application.
Electron’s process model explains the distinction between the main and renderer processes. A file operation requested through the interface may pass through another layer. When it fails, you need to know whether the interface sent the command, the main process received it, and the result returned to the correct window.
Check that exposed operations reject invalid arguments. Enabling context isolation alone does not guarantee safe communication. The documentation warns against exposing a general IPC interface without filtering arguments. Functional tests of allowed and rejected operations complement a security review, rather than replace it.
Isolate each run’s profile and files
A working directory is not enough if the application uses a shared user profile, saved login or last opened document. Identify the stores your product uses and prepare separate test data for concurrent runs. A test must not use someone’s personal profile or delete it during cleanup.
After a normal shutdown, check that the data was saved. After a forced crash, check recovery against the product requirements, rather than assume every unfinished step must have been saved. An offline scenario should verify a clear error and a return to a usable state when the connection is restored. If the product supports local work, also check that it is sent later without unwanted duplicates.
How to investigate a CI failure
When the application fails to start, first distinguish a product failure from a broken test environment. Check the package path, permissions, automation connection settings and graphical environment support. Electron describes virtual display support for CI, such as Xvfb on Linux. This is not a recipe for every operating system or confirmation of a particular CI provider’s current setup.
Include the build identity, platform, last completed step and available logs from both the main and renderer processes. State whether the native dialog was actually controlled or replaced. If the tool could not launch the application, the scenario remains unverified. Successful web tests do not close that gap.
What you gain
The team verifies the application in the form delivered to the customer, not just its web components. This coverage can detect errors in startup, window handling and work with local files before release, while faster web tests continue to provide early feedback.
Results from the individual layers help narrow down whether the probable cause lies in the business logic, renderer layer or desktop integration.
Next step
List three features that distinguish your Electron application from its web version, such as working with files, multiple windows and updates. Verify one of them in a pilot using an actual application build. If the product also includes a standalone website, compare the options with automated testing of web applications.