Authors Playwright `_electron` tests for packaged Electron desktop apps - launches the app via `electron.launch({ args })`, returns an `ElectronApplication` handle, drives renderer windows as Playwright `Page` objects, and probes the main process via `electronApp.evaluate(({ app, BrowserWindow }) => …)`. Distinct from ordinary browser page automation: this wraps the `_electron` API for launching packaged Electron apps and probing main + renderer processes. Includes the legacy Spectron reference and Spectron-to-Playwright migration shopping list (references/spectron-migration.md). Use for end-to-end tests of Electron apps where main-process state, IPC, and renderer DOM must all be asserted from one suite, or when migrating a deprecated Spectron suite.
72
90%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
_electronSpectron was a Node.js library that drove Electron applications through
ChromeDriver + the legacy WebDriverIO API - for several years the only
sanctioned end-to-end driver for Electron apps. Per the
Spectron repository: "Spectron is officially deprecated as of
February 1, 2022." The final release was v19.0.0 (published 2022-02-02),
pinned to Electron ^19.0.0; the repository is archived read-only. No new
project should start on Spectron - see SKILL.md for the
Playwright _electron workflow.
// Legacy Spectron - DO NOT use for new code
const Application = require('spectron').Application;
const app = new Application({
path: '/path/to/electron/MyApp.app/Contents/MacOS/MyApp',
});
before(async () => {
await app.start();
});
after(async () => {
if (app && app.isRunning()) {
await app.stop();
}
});
it('opens a window', async () => {
const count = await app.client.getWindowCount();
assert.strictEqual(count, 1);
});_electron equivalent// Modern replacement (per electrontest)
const { _electron: electron } = require('playwright');
let electronApp;
beforeAll(async () => {
electronApp = await electron.launch({ args: ['.'] });
});
afterAll(async () => {
await electronApp.close();
});
test('opens a window', async () => {
const windowCount = electronApp.windows().length;
expect(windowCount).toBe(1);
});| Spectron concept | Playwright _electron replacement |
|---|---|
new Application({ path }) | electron.launch({ args: ['.'] }) (electrontest) |
app.start() / app.stop() | electronApp.launch() / electronApp.close() |
app.client.<webdriver-method> | page = await electronApp.firstWindow(); then standard page.<method> (electrontest) |
app.browserWindow.<method> (sync RPC into main process) | electronApp.evaluate(({ BrowserWindow }) => { … }) - typed handle (electrontest) |
Window counting via app.client.getWindowCount() | electronApp.windows().length |
| ChromeDriver binary lifecycle | Implicit - Playwright bundles Chromium and exposes packaged-app launch directly |
Plan migration test-file-by-test-file, not big-bang: tag each file as
migrated, run both suites in CI until the Spectron set is empty, then delete
spectron from package.json. There is no first-party codemod, and
Spectron's main-process RPC (app.electron.<…>) has no 1:1
electronApp.evaluate() mapping for every case - some tests need a small
refactor. Projects already on WDIO for browser tests may prefer
wdio-electron-service (electrontest) as the migration
target instead.
spectron: 19.0.0 and electron: ^19.0.0 - newer Electron breaks
Spectron's ChromeDriver bridge (spectronrepo).