Skip to content

Commit f148be7

Browse files
committed
test: local chrome
1 parent 8693504 commit f148be7

3 files changed

Lines changed: 42 additions & 3 deletions

File tree

.github/workflows/auto-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ jobs:
2424
with:
2525
node-version: 24
2626
cache: 'pnpm'
27+
- name: Install Google Chrome
28+
run: |
29+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg
30+
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
31+
sudo apt-get update
32+
sudo apt-get install -y google-chrome-stable
2733
- run: pnpm i
2834
- run: npx playwright install --with-deps
2935
- run: pnpm build

e2e/fixtures.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,38 @@ export const { name } = packageJson
1111
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1212
export const extensionPath = path.resolve(__dirname, '../dist')
1313

14-
const chromeExePath = 'C:/Program Files/Google/Chrome/Application/chrome.exe'
14+
// Chrome executable path detection for different platforms
15+
function getChromeExecutablePath(): string | undefined {
16+
const platform = process.platform
17+
if (platform === 'win32') {
18+
const possiblePaths = [
19+
'C:/Program Files/Google/Chrome/Application/chrome.exe',
20+
'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
21+
process.env.LOCALAPPDATA + '/Google/Chrome/Application/chrome.exe',
22+
]
23+
for (const chromePath of possiblePaths) {
24+
if (chromePath && fs.existsSync(chromePath)) {
25+
return chromePath
26+
}
27+
}
28+
} else if (platform === 'darwin') {
29+
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
30+
} else if (platform === 'linux') {
31+
const possiblePaths = [
32+
'/usr/bin/google-chrome',
33+
'/usr/bin/google-chrome-stable',
34+
'/usr/bin/chromium-browser',
35+
]
36+
for (const chromePath of possiblePaths) {
37+
if (fs.existsSync(chromePath)) {
38+
return chromePath
39+
}
40+
}
41+
}
42+
return undefined
43+
}
44+
45+
const chromeExePath = getChromeExecutablePath()
1546
export const test = base.extend<{
1647
context: BrowserContext
1748
extensionId: string
@@ -34,6 +65,8 @@ export const test = base.extend<{
3465

3566
const context = await chromium.launchPersistentContext('', {
3667
headless: false,
68+
// Use Chrome executable for video codec support, fallback to Chromium if not found
69+
...(chromeExePath ? { executablePath: chromeExePath } : {}),
3770
args: [
3871
'--disable-features=DisableLoadExtensionCommandLineSwitch',
3972
// ...(headless ? ['--headless=new'] : []),
@@ -52,7 +85,6 @@ export const test = base.extend<{
5285
recordVideo: {
5386
dir: videoDir,
5487
},
55-
// executablePath: chromeExePath,
5688
})
5789
await use(context)
5890
// let [serviceWorker] = context.serviceWorkers()

playwright.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default defineConfig({
88
use: {
99
headless: false,
1010
video: 'on',
11-
channel: 'chrome',
11+
// Note: executablePath is set in fixtures.ts to use Chrome for video codec support
12+
// while still allowing extension loading via --load-extension args
1213
},
1314
// webServer: {
1415
// command: 'npm run dev',

0 commit comments

Comments
 (0)