File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9191 - name : 🏗️ Build project
9292 run : pnpm build
9393
94- - name : ♿ Accessibility audit (Lighthouse)
95- run : pnpx @lhci/cli autorun
94+ - name : ♿ Accessibility audit (Lighthouse - dark & light mode )
95+ run : ./scripts/lighthouse-a11y.sh
9696 env :
9797 LHCI_GITHUB_APP_TOKEN : ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
Original file line number Diff line number Diff line change 99 " http://localhost:3000/nuxt"
1010 ],
1111 "numberOfRuns" : 1 ,
12+ "puppeteerScript" : " ./lighthouse-setup.js" ,
1213 "settings" : {
1314 "onlyCategories" : [" accessibility" ],
1415 "skipAudits" : [" valid-source-maps" ]
Original file line number Diff line number Diff line change 1+ /**
2+ * Lighthouse CI puppeteer setup script.
3+ * Sets the color mode (light/dark) before running accessibility audits.
4+ *
5+ * The color mode is determined by the LIGHTHOUSE_COLOR_MODE environment variable.
6+ * If not set, defaults to 'dark'.
7+ */
8+
9+ /** @param {import('puppeteer').Browser } browser */
10+ export default async function setup ( browser , { url } ) {
11+ const colorMode = process . env . LIGHTHOUSE_COLOR_MODE || 'dark'
12+ const page = await browser . newPage ( )
13+
14+ // Set localStorage before navigating so @nuxtjs /color-mode picks it up
15+ await page . evaluateOnNewDocument ( mode => {
16+ localStorage . setItem ( 'npmx-color-mode' , mode )
17+ } , colorMode )
18+
19+ await page . goto ( url , { waitUntil : 'networkidle0' } )
20+
21+ // Also set the data-theme attribute directly to ensure the mode is applied
22+ await page . evaluate ( mode => {
23+ document . documentElement . setAttribute ( 'data-theme' , mode )
24+ } , colorMode )
25+
26+ // Close the page - Lighthouse will open its own
27+ await page . close ( )
28+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Run Lighthouse accessibility tests in both light and dark mode
3+ #
4+ # This script runs lhci autorun twice, once for each color mode.
5+ # The LIGHTHOUSE_COLOR_MODE env var is read by lighthouse-setup.js
6+ # to set the appropriate theme before each audit.
7+
8+ set -e
9+
10+ echo " 🌙 Running Lighthouse accessibility audit (dark mode)..."
11+ LIGHTHOUSE_COLOR_MODE=dark pnpx @lhci/cli autorun
12+
13+ echo " "
14+ echo " ☀️ Running Lighthouse accessibility audit (light mode)..."
15+ LIGHTHOUSE_COLOR_MODE=light pnpx @lhci/cli autorun
16+
17+ echo " "
18+ echo " ✅ Accessibility audits completed for both color modes"
You can’t perform that action at this time.
0 commit comments