Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 54 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ jobs:
node-version: ${{ matrix.node}}
cache: 'npm'
- run: npm ci
# HACK: Force a TTY to enable browser-driver-manager to manipulate stdout.
- shell: 'script -q -e -c "bash {0}"'
run: npx browser-driver-manager install chrome@145
working-directory: packages/puppeteer
- uses: browser-actions/setup-chrome@v1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same setup-chrome block repeats in six jobs intentionally — composite actions aren't worth introducing for a five-line snippet, and YAML anchors don't play nicely with uses:. To override Chrome version repo-wide: set a CHROME_VERSION repository variable (Settings → Variables) to something like 120 or beta; unset it to track stable. install-chromedriver: true guarantees a version-matched driver beside the browser, and we hoist both outputs into $GITHUB_ENV so subsequent npm run steps inherit them — that's what fixes the original mismatch where the chromedriver npm pin and the runner-image Chrome had drifted apart.

id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
Comment thread
Garbee marked this conversation as resolved.
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run build --workspace=packages/puppeteer
- run: npm run coverage --workspace=packages/puppeteer
- run: npm run test:export --workspace=packages/puppeteer
Expand All @@ -56,10 +61,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
# HACK: Force a TTY to enable browser-driver-manager to manipulate stdout.
- shell: 'script -q -e -c "bash {0}"'
run: npx browser-driver-manager install chrome@145
working-directory: packages/cli
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run coverage --workspace=packages/cli

webdriverjs:
Expand All @@ -74,10 +84,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
# HACK: Force a TTY to enable browser-driver-manager to manipulate stdout.
- shell: 'script -q -e -c "bash {0}"'
run: npx browser-driver-manager install chrome@145
working-directory: packages/webdriverjs
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run build --workspace=packages/webdriverjs
- run: npm run coverage --workspace=packages/webdriverjs
- run: npm run test:export --workspace=packages/webdriverjs
Expand All @@ -94,10 +109,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
# HACK: Force a TTY to enable browser-driver-manager to manipulate stdout.
- shell: 'script -q -e -c "bash {0}"'
run: npx browser-driver-manager install chrome@145
working-directory: packages/webdriverio
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run build --workspace=packages/webdriverio
- run: npm run coverage --workspace=packages/webdriverio
- run: npm run test:export --workspace=packages/webdriverio
Expand Down Expand Up @@ -149,7 +169,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
- run: npx playwright install --with-deps
- uses: browser-actions/setup-chrome@v1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playwright now gets the same setup-chrome treatment instead of npx playwright install --with-deps. install-dependencies: true on the action covers the OS libs, and Playwright launches our binary via executablePath (see axe-playwright.spec.ts), so we never download Playwright's own Chromium build in CI. Local dev is unaffected because the spec falls back to Playwright's bundled Chromium when CHROME_TEST_PATH is empty.

id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run build --workspace=packages/playwright
- run: npm run coverage --workspace=packages/playwright
- run: npm run test:export --workspace=packages/playwright
Expand All @@ -166,6 +194,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
- uses: browser-actions/setup-chrome@v1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This job had no Chrome install step before. Now it gets the same env-var contract as the rest. Pair this with the --no-sandbox / --disable-dev-shm-usage flags added to wdio.conf.ts — without those the setup-chrome Chromium binary's zygote can't sandbox itself on Ubuntu 24 (restricted user-namespace clone) and Chrome exits immediately. That's the regression that initially failed this job after the workflow change.

id: setup-chrome
with:
chrome-version: ${{ vars.CHROME_VERSION || 'stable' }}
install-chromedriver: true
install-dependencies: true
- run: |
echo "CHROME_TEST_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_TEST_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> "$GITHUB_ENV"
- run: npm run test --workspace=test/wdio

axe_core_test:
Expand Down
99 changes: 0 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,5 @@
"*.{json,css,md,html}": [
"prettier --write"
]
},
"dependencies": {
"browser-driver-manager": "^2.0.0"
}
}
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"chromedriver": "latest",
"colors": "^1.4.0",
"commander": "^9.4.1",
"dotenv": "^17.2.2",
"selenium-webdriver": "~4.41.0"
},
"devDependencies": {
Expand Down
7 changes: 0 additions & 7 deletions packages/cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ import fs from 'fs';
import path from 'path';
import colors from 'colors';
import type { AxeResults, UnlabelledFrameSelector } from 'axe-core';
import { config } from 'dotenv';
import os from 'os';

const HOME_DIR = os.homedir();
const BDM_CACHE_DIR = path.resolve(HOME_DIR, '.browser-driver-manager');

config({ path: path.resolve(BDM_CACHE_DIR, '.env'), quiet: true });

export const { CHROME_TEST_PATH, CHROMEDRIVER_TEST_PATH } = process.env;

Expand Down
14 changes: 12 additions & 2 deletions packages/cli/src/lib/webdriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ describe('startDriver', () => {
before(() => {
assert(
process.env.CHROME_TEST_PATH,
'CHROME_TEST_PATH is not set. Run `npx browser-driver-manager install chrome`'
[
'CHROME_TEST_PATH is not set.',
'Install Chrome: npx @puppeteer/browsers install chrome@stable',
'The command prints the resolved binary path; export it as CHROME_TEST_PATH.',
'e.g. export CHROME_TEST_PATH="$(npx @puppeteer/browsers install chrome@stable | awk \'{print $2}\')"'
].join('\n')
);
assert(
process.env.CHROMEDRIVER_TEST_PATH,
'CHROMEDRIVER_TEST_PATH is not set. Run `npx browser-driver-manager install chrome`'
[
'CHROMEDRIVER_TEST_PATH is not set.',
'Install ChromeDriver: npx @puppeteer/browsers install chromedriver@stable',
'The command prints the resolved binary path; export it as CHROMEDRIVER_TEST_PATH.',
'e.g. export CHROMEDRIVER_TEST_PATH="$(npx @puppeteer/browsers install chromedriver@stable | awk \'{print $2}\')"'
].join('\n')
);
});
beforeEach(() => {
Expand Down
5 changes: 4 additions & 1 deletion packages/playwright/test/axe-playwright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ describe('@axe-core/playwright', () => {

beforeEach(async () => {
browser = await chromium.launch({
args: ['--disable-dev-shm-usage']
args: ['--disable-dev-shm-usage'],
...(process.env.CHROME_TEST_PATH && {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playwright supports launching arbitrary Chromium-compatible binaries via executablePath. Conditional spread preserves the local-dev path: unset env var → Playwright's bundled Chromium; set env var → setup-chrome's binary. No --with-deps install needed in the workflow because setup-chrome's install-dependencies: true handles the OS libs.

executablePath: process.env.CHROME_TEST_PATH
})
Comment thread
Garbee marked this conversation as resolved.
Outdated
});
const context = await browser.newContext();
page = await context.newPage();
Expand Down
5 changes: 4 additions & 1 deletion packages/puppeteer/test/esmTest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const options = {};
if (process.env.CI) {
options.args = [];
options.args.push('--no-sandbox', '--disable-setuid-sandbox');
options.executablePath = '/usr/bin/google-chrome-stable';
}

if (process.env.CHROME_TEST_PATH) {
options.executablePath = process.env.CHROME_TEST_PATH;
}

async function integrationTest() {
Expand Down
4 changes: 4 additions & 0 deletions packages/puppeteer/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@ export function puppeteerOpts(): LaunchOptions {
options.args.push('--no-sandbox', '--disable-setuid-sandbox');
}

if (process.env.CHROME_TEST_PATH) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same fallback pattern as the playwright and wdio configs: when CI set CHROME_TEST_PATH, use that binary; otherwise let Puppeteer launch its bundled Chromium. The previous /usr/bin/google-chrome-stable hardcode in the sibling esmTest.mjs is gone for the same reason — system Chrome paths aren't portable across runner images, and now we don't need to guess.

options.executablePath = process.env.CHROME_TEST_PATH;
}

return options;
}
22 changes: 13 additions & 9 deletions packages/webdriverio/test/axe-webdriverio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ import { ChildProcessWithoutNullStreams } from 'child_process';
import { fixturesPath } from 'axe-test-fixtures';
import sinon from 'sinon';

const {
getFreePort,
connectToChromeDriver,
loadBdmEnv
} = require('./testUtils');

loadBdmEnv();
const { getFreePort, connectToChromeDriver } = require('./testUtils');

// devtools protocol was removed in WDIO v9.
// require('webdriverio/package.json') fails when the package uses an exports
Expand Down Expand Up @@ -55,11 +49,21 @@ describe('@axe-core/webdriverio', () => {
port = await getFreePort();
assert(
process.env.CHROME_TEST_PATH,
'CHROME_TEST_PATH is not set. Run `npx browser-driver-manager install chrome`'
[
'CHROME_TEST_PATH is not set.',
'Install Chrome: npx @puppeteer/browsers install chrome@stable',
'The command prints the resolved binary path; export it as CHROME_TEST_PATH.',
'e.g. export CHROME_TEST_PATH="$(npx @puppeteer/browsers install chrome@stable | awk \'{print $2}\')"'
].join('\n')
);
assert(
process.env.CHROMEDRIVER_TEST_PATH,
'CHROMEDRIVER_TEST_PATH is not set. Run `npx browser-driver-manager install chrome`'
[
'CHROMEDRIVER_TEST_PATH is not set.',
'Install ChromeDriver: npx @puppeteer/browsers install chromedriver@stable',
'The command prints the resolved binary path; export it as CHROMEDRIVER_TEST_PATH.',
'e.g. export CHROMEDRIVER_TEST_PATH="$(npx @puppeteer/browsers install chromedriver@stable | awk \'{print $2}\')"'
].join('\n')
);
const path = process.env.CHROMEDRIVER_TEST_PATH;
chromedriverProcess = child_process.spawn(path as string, [
Expand Down
8 changes: 6 additions & 2 deletions packages/webdriverio/test/esmTest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { fixturesPath } from 'axe-test-fixtures';
import { spawn } from 'child_process';
import { getFreePort, connectToChromeDriver } from './testUtils.js';

const { default: { path: chromedriverPath } } = await import('chromedriver');
const chromedriverPath =

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix for PR #1344. Previously this harness used the chromedriver npm package (pinned ^146) and launched it against whatever Chrome the runner image had (148), producing the "session not created — only supports Chrome 146" failure. Reading CHROMEDRIVER_TEST_PATH first means CI uses the setup-chrome-installed driver (version-matched to CHROME_TEST_PATH); the npm package stays as the local-dev fallback so npm test without env vars still works.

process.env.CHROMEDRIVER_TEST_PATH ||
(await import('chromedriver')).default.path;
const chromeBinary = process.env.CHROME_TEST_PATH;

assert(typeof defaultExport === 'function', 'default export is not a function');
assert(typeof AxeBuilder === 'function', 'named export is not a function');
Expand All @@ -35,7 +38,8 @@ async function integrationTest() {
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--headless', '--no-sandbox']
args: ['--headless', '--no-sandbox'],
...(chromeBinary && { binary: chromeBinary })

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spread is conditional so the unset case leaves capabilities untouched and webdriverio's Selenium Manager finds a system Chrome. Setting binary: undefined here would override Selenium Manager and break local dev.

Comment thread
Garbee marked this conversation as resolved.
Outdated
}
},
logLevel: 'error'
Expand Down
Loading
Loading