CtrlK
BlogDocsLog inGet started
Tessl Logo

testland/electron-spectron

Legacy reference for Spectron - Electron's original ChromeDriver-based testing framework, officially deprecated 2022-02-01 at v19.0.0. Documents what Spectron was, the architectural reason it became unmaintainable, the migration path to Playwright `_electron`, and the residual support contract for projects still on Spectron. Use only when auditing a legacy suite or planning a migration off Spectron - for new work use Playwright's `_electron` API.

74

Quality

93%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

spectron-migration.mdreferences/

Spectron -> Playwright migration reference

The before/after code and the concept-by-concept mapping, kept out of the SKILL spine. See SKILL.md for the deprecation facts and the residual support contract, and electron-playwright for the full Playwright _electron authoring, running, and CI workflow.

Sources: Spectron repository (archived), Electron Automated Testing tutorial.

Before: a Spectron test

// 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);
});

After: the Playwright _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);
});

Migration shopping list

A Spectron-to-Playwright migration touches:

Spectron conceptPlaywright _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 lifecycleImplicit - 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.

SKILL.md

tile.json