-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
60 lines (56 loc) · 1.97 KB
/
Copy pathplaywright.config.ts
File metadata and controls
60 lines (56 loc) · 1.97 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
import { defineConfig, devices } from '@playwright/test';
import { existsSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import dotenv from 'dotenv';
import { DOCS_FIXTURE_INDEX_URL } from './e2e/docs-fixture.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const PORT = process.env.E2E_PORT ?? '3100';
const BASE_URL = `http://localhost:${PORT}`;
/**
* Load env vars from .env.e2e (written by e2e setup).
* These are passed to the webServer so the Next.js dev server
* has a working OAUTH_DATABASE_URL.
*/
function loadE2eEnv(): Record<string, string> {
const envFile = path.resolve(__dirname, '.env.e2e');
if (!existsSync(envFile)) return {};
const parsed = dotenv.config({ path: envFile, processEnv: {} });
return (parsed.parsed as Record<string, string>) ?? {};
}
export default defineConfig({
globalSetup: './e2e/global-setup.ts',
testDir: './e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'list',
use: {
baseURL: BASE_URL,
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: {
command: `pnpm exec next dev --port ${PORT}`,
url: BASE_URL,
// The suite owns this server so webServer.env always reaches it.
reuseExistingServer: false,
timeout: 60_000,
env: {
// Load fresh values from .env.e2e for the webServer subprocess.
...loadE2eEnv(),
// Read the docs index from the fixture server that global setup starts, so
// no merge-gating test depends on neon.com being reachable. Set here and
// not in global setup: Playwright starts the web server as a plugin task,
// which runs before global setup, so anything global setup puts on
// process.env arrives too late for this process.
NEON_DOCS_INDEX_URL: DOCS_FIXTURE_INDEX_URL,
},
},
});