From: Ardis Lu Date: Thu, 21 May 2026 05:41:55 +0000 (-0700) Subject: Allow passing options to Playwright X-Git-Tag: v0.1.2~15 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=2ae2c551d7eba1ac74d36cbf622c1dd44de2930f;p=envpass Allow passing options to Playwright Makes it easier to debug Playwright tests. --- diff --git a/test/setup.js b/test/setup.js index 0e0db6d..810753a 100644 --- a/test/setup.js +++ b/test/setup.js @@ -10,6 +10,12 @@ import { chromium } from 'playwright-core'; import { getPrf, BROWSER } from '#src/getPrf.js'; /** @import { GetPrfResult } from '#src/getPrf.js'; */ +/** + * @typedef {Object} SetupPlaywrightOptions + * @property {boolean} [headless] Whether to launch the browser in `headless` mode or not. The + * default value is `true`. + */ + /** * @typedef {Object} SetupPlaywrightResult * @property {Page} page Playwright `Page` instance to control the browser. @@ -20,10 +26,12 @@ import { getPrf, BROWSER } from '#src/getPrf.js'; /** * Setup Playwright to test passkeys, with appropriate teardown hook. * @param {TestContext} t Test context to add `after` hook to. + * @param {SetupPlaywrightOptions} [options] Selected debugging options to pass to Playwright. * @returns {Promise} */ -export async function setupPlaywright(t) { - const browser = await chromium.launch(); +export async function setupPlaywright(t, options = {}) { + const { headless = true } = options; + const browser = await chromium.launch({ headless }); const context = await browser.newContext(); const page = await context.newPage(); const cdp = await context.newCDPSession(page);