Electron App Testing Guide (Desktop Apps)

Electron apps bundle Chromium and Node into a native-like desktop app. They are JavaScript-first with access to OS-level APIs. Testing them combines web testing (for the renderer) with Node and IPC te

February 26, 2026 · 3 min read · Testing Guides

Electron apps bundle Chromium and Node into a native-like desktop app. They are JavaScript-first with access to OS-level APIs. Testing them combines web testing (for the renderer) with Node and IPC testing (for the main process). This guide covers the 2026 approach.

What Electron is

Testing each tier matters.

Unit tests

Renderer code (React / Vue / etc.)

Jest / Vitest like any web app. Mock window.electronAPI:


global.electronAPI = {
  saveFile: jest.fn(() => Promise.resolve({path: '/tmp/saved.txt'})),
  loadFile: jest.fn(() => Promise.resolve('content'))
};

Main process code

Jest in Node environment. Mock electron module:


jest.mock('electron', () => ({
  app: { whenReady: jest.fn(() => Promise.resolve()) },
  BrowserWindow: jest.fn(() => ({ loadURL: jest.fn(), webContents: { send: jest.fn() } })),
  ipcMain: { handle: jest.fn() }
}));

IPC / contextBridge

Test each exposed API:


test('save-file invokes IPC with content', async () => {
  const mockSend = jest.fn(() => Promise.resolve({path: 'out.txt'}));
  const api = createElectronAPI(mockSend);
  const result = await api.saveFile('hello');
  expect(mockSend).toHaveBeenCalledWith('save-file', 'hello');
});

End-to-end with Playwright

Playwright supports Electron directly:


import { _electron as electron } from '@playwright/test';

test('app launches and saves file', async () => {
  const app = await electron.launch({ args: ['.'] });
  const window = await app.firstWindow();
  await window.click('text=New Document');
  await window.fill('[contenteditable]', 'Hello');
  await window.click('text=Save');
  // Assert saved state
  await window.waitForSelector('text=Saved');
  await app.close();
});

Works cross-platform (Linux / macOS / Windows runners).

Spectron (deprecated)

Older tool, no longer maintained. Use Playwright's Electron support.

Test strategy

  1. Renderer unit tests: majority. Fast.
  2. Main process unit tests: business logic. Fast.
  3. IPC contract tests: API correctness across boundary.
  4. Playwright E2E: critical flows. Slower.

Auto-update testing

Electron apps update themselves. Test:

Harder to automate fully; manual pass per release on auto-update code.

Platform specifics

macOS

Windows

Linux

Test each platform's install / uninstall / update cycle.

Security

Security audit per release — Electron carries Chromium's CVE surface.

Accessibility

Electron uses Chromium's accessibility. Similar to web:

Test with platform-native screen readers.

How SUSA tests Electron

SUSA can drive Electron apps similarly to web apps via Playwright's Electron support. For dedicated desktop automation at scale, SUSA integrates with Playwright's _electron.launch().


# Example (pseudo — Electron testing is a niche path)
susatest-agent test path/to/electron/app --framework electron --steps 200

Common bugs

  1. Memory leak in renderer — Electron keeps renderer process alive; leaks accumulate
  2. IPC race: multiple concurrent invokes with same channel
  3. Menu item disabled when it should be enabled — state not propagated
  4. Window close asks "save" even with no changes — dirty state wrong
  5. Cross-platform path handling/ vs \, case sensitivity

Electron is powerful but bloated. Test discipline keeps desktop apps stable.

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free