-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
66 lines (60 loc) · 2.43 KB
/
Copy pathplaywright.config.ts
File metadata and controls
66 lines (60 loc) · 2.43 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
import { defineConfig, devices } from "@playwright/test";
/**
* Playwright configuration.
*
* The tests cover the two use cases the assessment asks for:
* e2e/server.spec.ts — the server use case: CRUD on an RSS feed
* e2e/client.spec.ts — the client use case: retrieving and reading a feed
*
* Playwright starts the application itself rather than assuming one is
* already running, so `npx playwright test` works from a clean checkout and
* in CI without a separate step to remember.
*/
const PORT = Number(process.env.PLAYWRIGHT_PORT ?? 3100);
const BASE_URL = process.env.PLAYWRIGHT_BASE_URL ?? `http://127.0.0.1:${PORT}`;
export default defineConfig({
testDir: "./e2e",
// The tests write to a shared database, so they run in sequence. Parallel
// workers here would produce failures that depend on scheduling rather than
// on the code, which is the least useful kind of test failure.
fullyParallel: false,
workers: 1,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
reporter: process.env.CI
? [["list"], ["html", { outputFolder: "playwright-report", open: "never" }]]
: [["list"], ["html", { outputFolder: "playwright-report", open: "never" }]],
timeout: 30_000,
expect: { timeout: 10_000 },
use: {
baseURL: BASE_URL,
// Deliberately not the machine's zone. The server below runs in UTC, so
// every run reproduces the server/browser split that a real deployment
// has and a laptop does not — which is how the hydration bug in
// lib/format.ts reached production in the first place.
timezoneId: "Asia/Bangkok",
locale: "en-AU",
trace: "retain-on-failure",
screenshot: "only-on-failure",
video: "retain-on-failure",
},
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
],
webServer: {
// A production build, not `next dev`: dev-mode compilation happens on
// first request, which makes the first assertion in every file wait on a
// compiler rather than on the application.
command: `npm run build && npx next start --port ${PORT}`,
url: `${BASE_URL}/api/health`,
reuseExistingServer: !process.env.CI,
timeout: 180_000,
env: {
DATABASE_URL: process.env.DATABASE_URL ?? "file:./dev.db",
SITE_URL: BASE_URL,
// Containers run UTC. Pinning it here means the tests see what the
// deployment sees rather than whatever the developer's clock says.
TZ: "UTC",
},
},
});