From 8912cf6002b942269633652be1de1169a368ece7 Mon Sep 17 00:00:00 2001 From: hanna-skryl Date: Wed, 19 Nov 2025 20:03:01 -0500 Subject: [PATCH 1/2] fix(plugin-axe): resolve pnpm install issue --- packages/plugin-axe/src/lib/runner/run-axe.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/plugin-axe/src/lib/runner/run-axe.ts b/packages/plugin-axe/src/lib/runner/run-axe.ts index 9f54eb23d..c91aa9038 100644 --- a/packages/plugin-axe/src/lib/runner/run-axe.ts +++ b/packages/plugin-axe/src/lib/runner/run-axe.ts @@ -1,4 +1,6 @@ import AxeBuilder from '@axe-core/playwright'; +import { createRequire } from 'node:module'; +import { dirname, join } from 'node:path'; import { type Browser, chromium } from 'playwright-core'; import type { AuditOutputs } from '@code-pushup/models'; import { @@ -71,6 +73,12 @@ export async function closeBrowser(): Promise { } } +/** + * Ensures Chromium browser binary is installed before running accessibility audits. + * + * Uses Node's module resolution and npm's bin specification to locate playwright-core CLI, + * working reliably with all package managers (npm, pnpm, yarn). + */ async function ensureBrowserInstalled(): Promise { if (browserChecked) { return; @@ -78,9 +86,14 @@ async function ensureBrowserInstalled(): Promise { logger.debug('Checking Chromium browser installation...'); + const require = createRequire(import.meta.url); + const pkgPath = require.resolve('playwright-core/package.json'); + const pkg = require(pkgPath); + const cliPath = join(dirname(pkgPath), pkg.bin['playwright-core']); + await executeProcess({ - command: 'npx', - args: ['playwright-core', 'install', 'chromium'], + command: 'node', + args: [cliPath, 'install', 'chromium'], }); browserChecked = true; From 625e7f7c0226f9541f42b287171ffbf0796acf74 Mon Sep 17 00:00:00 2001 From: hanna-skryl Date: Thu, 20 Nov 2025 10:29:21 -0500 Subject: [PATCH 2/2] fix(plugin-axe): address ESLint warnings --- packages/plugin-axe/src/lib/runner/run-axe.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/plugin-axe/src/lib/runner/run-axe.ts b/packages/plugin-axe/src/lib/runner/run-axe.ts index c91aa9038..7aba6ea82 100644 --- a/packages/plugin-axe/src/lib/runner/run-axe.ts +++ b/packages/plugin-axe/src/lib/runner/run-axe.ts @@ -1,6 +1,6 @@ -import AxeBuilder from '@axe-core/playwright'; +import { AxeBuilder } from '@axe-core/playwright'; import { createRequire } from 'node:module'; -import { dirname, join } from 'node:path'; +import path from 'node:path'; import { type Browser, chromium } from 'playwright-core'; import type { AuditOutputs } from '@code-pushup/models'; import { @@ -11,8 +11,10 @@ import { } from '@code-pushup/utils'; import { toAuditOutputs } from './transform.js'; +/* eslint-disable functional/no-let */ let browser: Browser | undefined; let browserChecked = false; +/* eslint-enable functional/no-let */ export async function runAxeForUrl( url: string, @@ -89,7 +91,7 @@ async function ensureBrowserInstalled(): Promise { const require = createRequire(import.meta.url); const pkgPath = require.resolve('playwright-core/package.json'); const pkg = require(pkgPath); - const cliPath = join(dirname(pkgPath), pkg.bin['playwright-core']); + const cliPath = path.join(path.dirname(pkgPath), pkg.bin['playwright-core']); await executeProcess({ command: 'node',