Skip to content

Commit 4f1250f

Browse files
committed
Add GitHub Actions CI pipeline for unit and e2e tests
- Add .github/workflows/ci.yml with two jobs: unit tests (Jest) and e2e tests (Playwright), triggered on every push and pull request - Update playwright.config.js for cross-platform CI compatibility: use plain chromium instead of msedge in CI, and python3 http server instead of PowerShell on non-Windows systems - Add test:e2e:ci npm script to run all e2e test suites Note: 4 pre-existing unit test failures exist in JSonSessionService.test.js (BrowserInfo object vs string mismatch). https://claude.ai/code/session_0112Ugwyx6RHkNhqW1bgSErN
1 parent 65c5daa commit 4f1250f

3 files changed

Lines changed: 76 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
unit-tests:
11+
name: Unit Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
cache: npm
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run unit tests
26+
run: npm test
27+
28+
e2e-tests:
29+
name: E2E Tests
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: 20
38+
cache: npm
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Install Playwright browsers
44+
run: npx playwright install chromium --with-deps
45+
46+
- name: Run E2E tests
47+
run: npm run test:e2e:ci
48+
49+
- name: Upload Playwright report
50+
uses: actions/upload-artifact@v4
51+
if: ${{ !cancelled() }}
52+
with:
53+
name: playwright-report
54+
path: playwright-report/
55+
retention-days: 30
56+
57+
- name: Upload test results
58+
uses: actions/upload-artifact@v4
59+
if: ${{ !cancelled() }}
60+
with:
61+
name: test-results
62+
path: test-results/
63+
retention-days: 30

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"test:e2e:debug": "playwright test smoke.spec.js basic-functionality.spec.js --debug",
2525
"test:e2e:report": "playwright show-report",
2626
"test:e2e:crop": "playwright test crop-screenshot.spec.js --headed",
27+
"test:e2e:ci": "playwright test smoke.spec.js basic-functionality.spec.js reports-export.spec.js crop-screenshot.spec.js",
2728
"test:all": "npm test && npm run test:e2e"
2829
},
2930
"repository": {

playwright.config.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
const { defineConfig, devices } = require('@playwright/test');
33
const path = require('path');
44

5+
const isCI = !!process.env.CI;
6+
const isWindows = process.platform === 'win32';
7+
58
/**
69
* Playwright configuration for Chrome Extension E2E testing
710
* @see https://playwright.dev/docs/test-configuration
@@ -14,9 +17,9 @@ module.exports = defineConfig({
1417

1518
// Test execution settings
1619
fullyParallel: false, // Extensions can't run fully parallel easily
17-
forbidOnly: !!process.env.CI,
18-
retries: process.env.CI ? 2 : 0,
19-
workers: process.env.CI ? 1 : 1, // Run tests sequentially for extensions
20+
forbidOnly: isCI,
21+
retries: isCI ? 2 : 0,
22+
workers: 1, // Run tests sequentially for extensions
2023

2124
// Reporter to use
2225
reporter: [
@@ -48,18 +51,20 @@ module.exports = defineConfig({
4851
name: 'chromium-extension',
4952
use: {
5053
...devices['Desktop Chrome'],
51-
// Edge has the best extension support with Playwright
52-
channel: 'msedge', // Use Microsoft Edge - works best with extensions
54+
// In CI (Linux), use plain chromium; locally on Windows/macOS use msedge
55+
...(isCI ? {} : { channel: 'msedge' }),
5356
// Note: Extension loading happens in test setup via helper functions
5457
},
5558
},
5659
],
5760

5861
// Run your local dev server before starting the tests
5962
webServer: {
60-
command: 'powershell -File ./start_test_server.ps1',
63+
command: isWindows
64+
? 'powershell -File ./start_test_server.ps1'
65+
: 'python3 -m http.server 8000',
6166
url: 'http://localhost:8000',
62-
reuseExistingServer: !process.env.CI,
67+
reuseExistingServer: !isCI,
6368
timeout: 10 * 1000,
6469
},
6570
});

0 commit comments

Comments
 (0)