-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
79 lines (72 loc) · 2.54 KB
/
Copy pathplaywright.config.ts
File metadata and controls
79 lines (72 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// filepath: playwright.config.ts
/**
* ============================================================================
* PLAYWRIGHT CONFIG — Extension Testing with Chrome
* ============================================================================
*
* This config sets up Playwright to test the CQD extension in a real browser.
*
* The trick: Playwright can load Chrome extensions by passing
* --load-extension and --disable-extensions-except to the Chromium
* args. We build the extension first (via `pnpm -C extension build`),
* then point Playwright at the built output directory.
*
* IMPORTANT: These tests need a REAL Chromium (not headless!) because
* Chrome extensions don't work in headless mode. Playwright handles
* this gracefully — it opens a real browser window for the tests.
*
* The test flow:
* 1. Build the extension (done in globalSetup)
* 2. Launch Chromium with the extension loaded
* 3. Navigate to a Classroom page (or a local fixture file)
* 4. Assert that CQD elements are injected
*
* For Classroom tests that need a real login, see
* tests/e2e/extension-smoke.spec.ts which can use a stored auth state.
*
* @author Adham
* @since v4.0.0
*/
import { defineConfig, devices } from '@playwright/test';
import path from 'node:path';
/**
* The path to the built extension output.
* After running `pnpm -C extension build`, WXT outputs to
* extension/.output/chrome-mv3/ (for Chrome MV3 builds).
*/
const EXTENSION_PATH = path.resolve(__dirname, 'extension/.output/chrome-mv3');
export default defineConfig({
testDir: './tests/e2e',
timeout: 60_000,
retries: 0,
workers: 1, // Extensions can't share browser instances
use: {
// No base URL — we'll navigate to Classroom or local fixtures
baseURL: undefined,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
projects: [
{
name: 'extension-chromium',
use: {
...devices['Desktop Chrome'],
// Launch with the extension loaded.
// headless: false is REQUIRED because extension APIs are unavailable in headless mode.
launchOptions: {
headless: false,
args: [
`--disable-extensions-except=${EXTENSION_PATH}`,
`--load-extension=${EXTENSION_PATH}`,
'--disable-blink-features=AutomationControlled',
'--no-first-run',
'--disable-default-apps',
],
},
},
},
],
// Global setup builds the extension before running tests.
globalSetup: './tests/e2e/global-setup.ts',
});