playwright-extension-fixtures
Use when writing or debugging Playwright tests for a Chromium browser extension: the persistent-context fixture that loads the extension and finds its ID, why…
от testland★ 18 звёзд на GitHub
Установить playwright-extension-fixtures в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
playwright-extension-fixtures
Overview
Every Playwright-driven Chromium-extension test starts the same way: a persistent context launched with two flags, a service-worker race, and an extension-ID extraction. Per the Playwright Chrome extensions docs, this fixture is the contract the assertion-level skills depend on - it's the foundation, not the test logic.
This SKILL.md is the "how to launch" layer - the Playwright fixture
pattern (launchPersistentContext + --disable-extensions-except +
--load-extension) shared by all extension tests. The "what to
assert" playbook per surface - popup, content script, background
messaging, storage, MV3 auto-suspend - lives in
references/extension-surface-tests.md
and builds on this fixture.
Composes with:
- references/extension-surface-tests.md - per-surface assertion recipes (popup, content script, messaging, storage persistence, auto-suspend) run from this fixture.
- references/reload-matrix.md - which edits require which reload; the manual
chrome://extensionsgesture this fixture automates. - references/storage-tests.md - the
chrome.storagearea / quota / event test suite run from this fixture's SW context. - references/manifest-v3-test-surface.md - the manifest fields the fixture is testing against.
When to use
- Authoring a Playwright test against any unpacked Chromium extension (popup, content script, service worker, options page, side panel, devtools page).
- Headless CI runs of an extension - the
channel: 'chromium'selection is what unlocks headless extension support per pw-ext. - Diagnosing a "tests pass locally headed, fail headless" bug - the channel / flag matrix in this skill is the first checkpoint.
- Sharing the fixture across multiple spec files in the same
repository (a
fixtures.tsthat every spec imports).
Authoring
The verbatim fixture file
Per pw-ext, fixtures.ts:
import { test as base, chromium, type BrowserContext } from '@playwright/test';
import path from 'path';
export const test = base.extend<{
context: BrowserContext;
extensionId: string;
}>({
context: async ({ }, use) => {
const pathToExtension = path.join(__dirname, 'my-extension');
const context = await chromium.launchPersistentContext('', {
channel: 'chromium',
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
],
});
await use(context);
await context.close();
},
extensionId: async ({ context }, use) => {
// for manifest v3:
let [serviceWorker] = context.serviceWorkers();
if (!serviceWorker)
serviceWorker = await context.waitForEvent('serviceworker');
const extensionId = serviceWorker.url().split('/')[2];
await use(extensionId);
},
});
export const expect = test.expect;
Field-by-field rationale
| Element | Why it matters per pw-ext |
|---|---|
chromium.launchPersistentContext('') |
"Extensions require a persistent context in Chromium" - launch() is non-persistent and extensions never load |
'' (userDataDir) |
Empty string = ephemeral temp dir (Playwright cleans up); replace with a fixed path to persist auth state across runs |
channel: 'chromium' |
The bundled Chromium channel; unlocks headless extension support per pw-ext |
--disable-extensions-except=$DIR |
Prevents any pre-installed extension from also loading and confusing assertions |
--load-extension=$DIR |
Loads the unpacked extension at $DIR (where manifest.json lives) |
context.serviceWorkers() |
Synchronous accessor - may be empty if the SW hasn't registered yet |
context.waitForEvent('serviceworker') |
Race-safe fallback when SW isn't yet up |
serviceWorker.url().split('/')[2] |
Service-worker URL is chrome-extension://<id>/<path>; index 2 is the ID |
Usage in spec files
Per pw-ext:
import { test, expect } from './fixtures';
test('example test', async ({ page }) => {
await page.goto('https://example.com');
await expect(page.locator('body')).toHaveText('Changed by my-extension');
});
test('popup page', async ({ page, extensionId }) => {
await page.goto(`chrome-extension://${extensionId}/popup.html`);
await expect(page.locator('body')).toHaveText('my-extension popup');
});
The fixture-injected page automatically belongs to the persistent
context - any content scripts the extension declares for the
navigated URL will already be attached.
Running
Local headed
npx playwright test
Defaults to headed for extensions (per pw-ext, non-chromium
channels require headed mode).
Local + CI headless
npx playwright test --headed=false
Requires `ch
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- .tessl-plugin/plugin.json
- references/extension-surface-tests.md
- references/manifest-matrix.md
- references/manifest-v3-test-surface.md
- references/reload-matrix.md
- references/storage-tests.md
- references/web-ext-firefox.md
FAQ
Что делает скилл playwright-extension-fixtures?
Use when writing or debugging Playwright tests for a Chromium browser extension: the persistent-context fixture that loads the extension and finds its ID, why an edit seems to have no effect (reload matrix), and popup, content-script, storage and MV3 service-worker tests.
Как установить скилл playwright-extension-fixtures?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл playwright-extension-fixtures запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…