Skip to content

Commit 4a85d2a

Browse files
committed
test(e2e): improve extension fixture for ci
Runs e2e tests under xvfb in CI to provide a virtual display Improves extension fixture by centralising browser launch args to reliably load the unpacked extension in CI, including load-extension, disable-extensions-except, no-first-run, disable-default-apps, and additional flags like --disable-gpu and --disable-dev-shm-usage Enables CI headless mode by appending headless flag when running in CI Removes hard-coded browser channel in favour of default chromium Waits for service worker with a 30s timeout to avoid CI hangs
1 parent 318890a commit 4a85d2a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: npm run build
3434

3535
- name: Run E2E tests
36-
run: npx playwright test --config=e2e/playwright.config.ts
36+
run: xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npx playwright test --config=e2e/playwright.config.ts
3737
env:
3838
CI: true
3939

e2e/helpers/extension-fixture.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,22 @@ export const test = base.extend<ExtensionFixtures>({
1010
context: async ({}, use) => {
1111
const extensionPath = path.join(__dirname, '..', '..', 'dist');
1212

13+
const args = [
14+
`--disable-extensions-except=${extensionPath}`,
15+
`--load-extension=${extensionPath}`,
16+
'--no-first-run',
17+
'--disable-default-apps',
18+
'--disable-gpu',
19+
'--disable-dev-shm-usage',
20+
];
21+
22+
if (process.env.CI) {
23+
args.push('--headless=new');
24+
}
25+
1326
const context = await chromium.launchPersistentContext('', {
1427
headless: false,
15-
channel: 'chromium',
16-
args: [
17-
`--disable-extensions-except=${extensionPath}`,
18-
`--load-extension=${extensionPath}`,
19-
'--no-first-run',
20-
'--disable-default-apps',
21-
],
28+
args,
2229
});
2330

2431
await use(context);
@@ -28,7 +35,7 @@ export const test = base.extend<ExtensionFixtures>({
2835
extensionId: async ({ context }, use) => {
2936
let serviceWorker = context.serviceWorkers()[0];
3037
if (!serviceWorker) {
31-
serviceWorker = await context.waitForEvent('serviceworker');
38+
serviceWorker = await context.waitForEvent('serviceworker', { timeout: 30000 });
3239
}
3340

3441
const extensionId = serviceWorker.url().split('/')[2];

0 commit comments

Comments
 (0)