Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches: ['**']
pull_request:
branches: [main, master]

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm test

e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Install Playwright browsers
run: npx playwright install chromium --with-deps

- name: Run E2E tests
run: npm run test:e2e:ci

- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30

- name: Upload test results
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-results
path: test-results/
retention-days: 30
2 changes: 0 additions & 2 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:e2e:debug": "playwright test smoke.spec.js basic-functionality.spec.js --debug",
"test:e2e:report": "playwright show-report",
"test:e2e:crop": "playwright test crop-screenshot.spec.js --headed",
"test:e2e:ci": "playwright test smoke.spec.js basic-functionality.spec.js reports-export.spec.js crop-screenshot.spec.js",
"test:all": "npm test && npm run test:e2e"
},
"repository": {
Expand Down
19 changes: 12 additions & 7 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
const { defineConfig, devices } = require('@playwright/test');
const path = require('path');

const isCI = !!process.env.CI;
const isWindows = process.platform === 'win32';

/**
* Playwright configuration for Chrome Extension E2E testing
* @see https://playwright.dev/docs/test-configuration
Expand All @@ -14,9 +17,9 @@ module.exports = defineConfig({

// Test execution settings
fullyParallel: false, // Extensions can't run fully parallel easily
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : 1, // Run tests sequentially for extensions
forbidOnly: isCI,
retries: isCI ? 2 : 0,
workers: 1, // Run tests sequentially for extensions

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

// Run your local dev server before starting the tests
webServer: {
command: 'powershell -File ./start_test_server.ps1',
command: isWindows
? 'powershell -File ./start_test_server.ps1'
: 'python3 -m http.server 8000',
url: 'http://localhost:8000',
reuseExistingServer: !process.env.CI,
reuseExistingServer: !isCI,
timeout: 10 * 1000,
},
});
Loading