Skip to content

Prompt to install missing Playwright browsers on dev #34410

@Sidnioulz

Description

@Sidnioulz

If addon-vitest is installed, consider prompting the user to install missing Playwright browsers on dev events.

This would let us safely skip Playwright install when --skip-install has been passed to init, without resulting in a broken Storybook Test setup. Currently, --skip-install still installs browsers, which could be considered a bug.

To do

  • Add playwright-core as a dep of addon-vitest (it's already a transitive dep)
  • Use below script to detect missing browsers with playwright-core
  • If they are missing, prompt the user to install them, default to yes
  • In init, respect --skip-install when it comes to downloading Playwright browsers
import {firefox, chromium, webkit} from 'playwright-core'
import fs from 'fs'
import {performance} from 'perf_hooks'

function isBrowserInstalled(browserType) {
  try {
    const execPath = browserType.executablePath();
    return fs.existsSync(execPath);
  } catch {
    return false;
  }
}

function measureExecutionTime(label, fn) {
  const startTime = performance.now();
  const result = fn();
  const durationMs = performance.now() - startTime;

  console.log(`${label}: ${result} (${durationMs.toFixed(2)} ms)`);
}

measureExecutionTime('Chromium', () => isBrowserInstalled(chromium));
measureExecutionTime('Firefox', () => isBrowserInstalled(firefox));
measureExecutionTime('WebKit', () => isBrowserInstalled(webkit));
Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Empathy Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions