import path from 'path'; import { test as base, chromium, type BrowserContext } from '@playwright/test'; export const test = base.extend<{ context: BrowserContext; extensionId: string; }>({ // eslint-disable-next-line no-empty-pattern context: async ({}, use) => { const pathToExtension = path.resolve(__dirname, '../dist'); const context = await chromium.launchPersistentContext('', { headless: false, devtools: false, args: [ `--headless=new`, `--disable-extensions-except=${pathToExtension}`, `--load-extension=${pathToExtension}`, '--disable-web-security', ], }); await use(context); await context.close(); }, extensionId: async ({ context }, use) => { let [background] = context.serviceWorkers(); if (!background) { background = await context.waitForEvent('serviceworker'); } const extensionId = background.url().split('/')[2]; await use(extensionId); }, }); export const { expect } = test;