Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

electron-playwright

БесплатноБез исполняемых скриптовНе проверен

Use whenever an Electron desktop app needs end-to-end tests, or a Spectron suite must be migrated: Playwright's _electron.launch, renderer windows as Pages…

testlandот testland★ 18 звёзд на GitHub

Об этом скилле

electron-playwright

Overview

Playwright ships a first-class _electron namespace that launches a packaged Electron app by executablePath and drives both the main process (Node.js, IPC, native modules) and renderer windows (Chromium DOMs) from a single test (pwelectron). Per Electron's own automated-testing tutorial (electrontest), Playwright is one of three sanctioned test stacks (alongside WebdriverIO and Selenium) for modern Electron projects.

Differentiation: unlike playwright-testing (which drives a running Chromium / Firefox / WebKit browser via the browser / context / page namespaces), electron-playwright uses the separate _electron namespace to launch a packaged binary by path and probe the main process via electronApp.evaluate() (pwelectronapp). Renderer-side page patterns (Page Object, accessibility-first locators, trace viewer) carry over.

For legacy Spectron suites, see references/spectron-migration.md; for the strategic frame, desktop-test-strategy-reference.

When to use

  • New Electron desktop app - pick Playwright _electron as the modern default per electrontest.
  • Existing Electron suite still on Spectron - see the migration shopping list in references/spectron-migration.md.
  • Tests need to assert main-process state (e.g., app.isPackaged, BrowserWindow count, IPC channel payloads) in addition to renderer DOM.
  • Tests need to exercise packaged-app behaviour (file associations, single-instance lock, custom protocol handlers) that is unreachable from browser-only Playwright.

Step 1 - Install

Per electrontest:

npm install --save-dev @playwright/test

Playwright's _electron module is bundled inside playwright / @playwright/test - no extra package is needed (pwelectron). Supported Electron versions per pwelectron: "Electron v12.2.0+, v13.4.0+, and v14+".

Step 2 - Author the first test

The canonical example from electrontest:

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

test('app launches and is not packaged in dev', async () => {
  const electronApp = await electron.launch({ args: ['.'] });

  // Main-process assertion: probe the Electron `app` module
  const isPackaged = await electronApp.evaluate(async ({ app }) => {
    return app.isPackaged;
  });
  expect(isPackaged).toBe(false);

  // Renderer assertion: take a screenshot of the first window
  const window = await electronApp.firstWindow();
  await window.screenshot({ path: 'intro.png' });

  await electronApp.close();
});

What's going on:

  • electron.launch({ args: ['.'] }) launches Electron with the current directory as the main-script argument (pwelectron). For a packaged app, pass executablePath to the packaged binary instead - its default per pwelectron is node_modules/.bin/electron.
  • electronApp.evaluate(pageFunction) runs pageFunction inside the main process; the first argument is "always the result of the require('electron') in the main app script" (pwelectronapp).
  • electronApp.firstWindow() "waits for the first application window to be opened" (pwelectronapp) and returns a Playwright Page - every standard playwright-testing locator (getByRole, getByLabel) works on it.

Step 3 - Launching a packaged binary

For tests of the packaged app (the artifact users install):

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

const PACKAGED_BIN = process.platform === 'win32'
  ? path.resolve('dist/win-unpacked/MyApp.exe')
  : process.platform === 'darwin'
    ? path.resolve('dist/mac/MyApp.app/Contents/MacOS/MyApp')
    : path.resolve('dist/linux-unpacked/myapp');

const electronApp = await electron.launch({
  executablePath: PACKAGED_BIN,
  args: [],
  env: { ...process.env, NODE_ENV: 'test' },
  recordVideo: { dir: 'test-results/videos' },
});

The executablePath, env, cwd, recordVideo, recordHar, and timeout options are documented on the _electron launch reference (pwelectron).

Step 4 - Probing main + renderer in one test

Multi-surface assertion - main process owns app lifecycle, renderer owns DOM:

test('opening a project loads it into the renderer', async () => {
  const electronApp = await electron.launch({ args: ['.'] });
  const window = await electronApp.firstWindow();

  // Renderer-side action via Playwright Page API
  await window.getByRole('button', { name: /op
Полный SKILL.md на GitHub

Установить electron-playwright в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.tessl-plugin/plugin.jsonevals/desktop-suite-that-only-runs-on-one-mac/criteria.jsonevals/desktop-suite-that-only-runs-on-one-mac/task.mdevals/electron-dialog-isolation/criteria.jsonevals/electron-dialog-isolation/task.mdevals/electron-evaluate-closure/criteria.jsonevals/electron-evaluate-closure/task.mdevals/electron-splash-window/criteria.jsonevals/electron-splash-window/task.mdevals/one-app-instance-shared-by-four-tests/criteria.jsonevals/one-app-instance-shared-by-four-tests/task.mdevals/open-project-test-that-waits-for-a-human/criteria.jsonevals/open-project-test-that-waits-for-a-human/task.mdevals/packaging-checks-that-go-green-on-a-broken-build/criteria.jsonevals/packaging-checks-that-go-green-on-a-broken-build/task.mdevals/security-bump-versus-the-legacy-driver/criteria.jsonevals/security-bump-versus-the-legacy-driver/task.mdreferences/electron-ci-and-api.mdreferences/spectron-migration.md

FAQ

Что делает скилл electron-playwright?

Use whenever an Electron desktop app needs end-to-end tests, or a Spectron suite must be migrated: Playwright's _electron.launch, renderer windows as Pages, main-process checks via electronApp.evaluate, and IPC and DOM assertions from one suite.

Как установить скилл electron-playwright?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл electron-playwright запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить electron-playwright с