|
1 | | -import { defineConfig, devices } from '@playwright/test' |
| 1 | +import { defineConfig, devices } from "@playwright/test"; |
2 | 2 |
|
3 | | -const isCI = !!process.env.CI |
4 | | -const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? 'http://localhost:9000' |
| 3 | +const isCI = !!process.env.CI; |
| 4 | +const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? "http://localhost:9000"; |
| 5 | +const e2eApiUrl = |
| 6 | + process.env.PLAYWRIGHT_API_BASE_URL ?? "http://localhost:55436"; |
5 | 7 |
|
6 | 8 | /** |
7 | 9 | * E2E smoke tests for BikeTracking frontend (User Login feature). |
8 | 10 | * |
9 | 11 | * Prerequisites: |
| 12 | + * Preferred: launch the full Aspire stack: (`dotnet run --project src/BikeTracking.AppHost`) |
| 13 | + * OR |
10 | 14 | * - Vite dev server running on http://localhost:9000 (`npm run dev`) |
11 | | - * - .NET API running on http://localhost:5436 (`dotnet run --project src/BikeTracking.Api`) |
12 | | - * OR launch the full Aspire stack: (`dotnet run --project src/BikeTracking.AppHost`) |
| 15 | + * - .NET API running on http://localhost:55436 (`dotnet run --no-launch-profile --project src/BikeTracking.Api`) |
13 | 16 | * |
14 | 17 | * Run: npx playwright test (from src/BikeTracking.Frontend) |
15 | 18 | */ |
16 | 19 | export default defineConfig({ |
17 | | - testDir: './tests/e2e', |
| 20 | + testDir: "./tests/e2e", |
18 | 21 | fullyParallel: false, |
19 | 22 | forbidOnly: isCI, |
20 | 23 | retries: isCI ? 1 : 0, |
21 | 24 | workers: 1, |
22 | | - reporter: [['list'], ['html', { open: 'never' }]], |
| 25 | + reporter: [["list"], ["html", { open: "never" }]], |
23 | 26 | use: { |
24 | 27 | baseURL, |
25 | | - trace: 'on-first-retry', |
| 28 | + trace: "on-first-retry", |
26 | 29 | }, |
27 | 30 | webServer: [ |
28 | 31 | { |
29 | | - command: 'dotnet run --project ../BikeTracking.Api', |
30 | | - url: 'http://localhost:5436/', |
31 | | - reuseExistingServer: !isCI, |
32 | | - stdout: 'pipe', |
33 | | - stderr: 'pipe', |
| 32 | + command: "dotnet run --no-launch-profile --project ../BikeTracking.Api", |
| 33 | + url: `${e2eApiUrl}/`, |
| 34 | + reuseExistingServer: false, |
| 35 | + stdout: "pipe", |
| 36 | + stderr: "pipe", |
34 | 37 | timeout: 180000, |
35 | 38 | env: { |
| 39 | + ASPNETCORE_URLS: e2eApiUrl, |
36 | 40 | // Use a dedicated E2E database so test runs never touch the local dev DB. |
37 | 41 | // ASP.NET Core maps ConnectionStrings__<name> to ConnectionStrings[name]. |
38 | | - ConnectionStrings__BikeTracking: 'Data Source=biketracking.e2e.db', |
| 42 | + ConnectionStrings__BikeTracking: "Data Source=biketracking.e2e.db", |
39 | 43 | }, |
40 | 44 | }, |
41 | 45 | { |
42 | | - command: 'npm run dev -- --host localhost --port 9000', |
43 | | - url: 'http://localhost:9000/login', |
44 | | - reuseExistingServer: !isCI, |
45 | | - stdout: 'pipe', |
46 | | - stderr: 'pipe', |
| 46 | + command: `VITE_API_BASE_URL=${e2eApiUrl} npm run dev -- --host localhost --port 9000`, |
| 47 | + url: "http://localhost:9000/login", |
| 48 | + reuseExistingServer: false, |
| 49 | + stdout: "pipe", |
| 50 | + stderr: "pipe", |
47 | 51 | timeout: 120000, |
48 | 52 | }, |
49 | 53 | ], |
50 | 54 | projects: [ |
51 | 55 | { |
52 | | - name: 'chromium', |
53 | | - use: { ...devices['Desktop Chrome'] }, |
| 56 | + name: "chromium", |
| 57 | + use: { ...devices["Desktop Chrome"] }, |
54 | 58 | }, |
55 | 59 | ], |
56 | | -}) |
| 60 | +}); |
0 commit comments