From 2ae2c551d7eba1ac74d36cbf622c1dd44de2930f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Wed, 20 May 2026 22:41:55 -0700 Subject: [PATCH] Allow passing options to Playwright Makes it easier to debug Playwright tests. --- test/setup.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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); -- 2.47.3