···11+/**
22+ * Lighthouse CI puppeteer setup script.
33+ * Sets the color mode (light/dark) before running accessibility audits.
44+ *
55+ * The color mode is determined by the LIGHTHOUSE_COLOR_MODE environment variable.
66+ * If not set, defaults to 'dark'.
77+ */
88+99+/** @param {import('puppeteer').Browser} browser */
1010+module.exports = async function setup(browser, { url }) {
1111+ const colorMode = process.env.LIGHTHOUSE_COLOR_MODE || 'dark'
1212+ const page = await browser.newPage()
1313+1414+ // Set localStorage before navigating so @nuxtjs/color-mode picks it up
1515+ await page.evaluateOnNewDocument(mode => {
1616+ localStorage.setItem('npmx-color-mode', mode)
1717+ }, colorMode)
1818+1919+ // Navigate and wait for DOM only - Lighthouse will do its own full load
2020+ await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 })
2121+2222+ // Close the page - Lighthouse will open its own with localStorage already set
2323+ await page.close()
2424+}
+18
scripts/lighthouse-a11y.sh
···11+#!/bin/bash
22+# Run Lighthouse accessibility tests in both light and dark mode
33+#
44+# This script runs lhci autorun twice, once for each color mode.
55+# The LIGHTHOUSE_COLOR_MODE env var is read by lighthouse-setup.cjs
66+# to set the appropriate theme before each audit.
77+88+set -e
99+1010+echo "🌙 Running Lighthouse accessibility audit (dark mode)..."
1111+LIGHTHOUSE_COLOR_MODE=dark pnpx @lhci/cli autorun --upload.githubStatusContextSuffix="/dark"
1212+1313+echo ""
1414+echo "☀️ Running Lighthouse accessibility audit (light mode)..."
1515+LIGHTHOUSE_COLOR_MODE=light pnpx @lhci/cli autorun --upload.githubStatusContextSuffix="/light"
1616+1717+echo ""
1818+echo "✅ Accessibility audits completed for both color modes"