]> git.ardis.lu - envpass/commitdiff
Allow passing options to Playwright
authorArdis Lu <ardisglu@gmail.com>
Thu, 21 May 2026 05:41:55 +0000 (22:41 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 21 May 2026 05:41:55 +0000 (22:41 -0700)
Makes it easier to debug Playwright tests.

test/setup.js

index 0e0db6d51a78caefe704a00fa9dae563db7256f5..810753ab8032484f2e61be57bae1aa65443885e0 100644 (file)
@@ -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<SetupPlaywrightResult>}
  */
-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);
This page took 0.035727 seconds and 4 git commands to generate.