-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
66 lines (61 loc) · 2.33 KB
/
Copy pathplaywright.config.ts
File metadata and controls
66 lines (61 loc) · 2.33 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 config for the hotcrm end-to-end suite.
*
* Previously this pointed `baseURL` at port 4004 while `pnpm dev` / `pnpm start`
* (and every doc) served 4001, and declared no `webServer`, so every spec hit a
* closed port. Nothing noticed because no workflow ran playwright and `verify`
* did not include it — the suite had been unrunnable for its entire life.
*/
const PORT = Number(process.env.HOTCRM_PORT ?? 4001);
export const BASE_URL = process.env.HOTCRM_BASE_URL ?? `http://localhost:${PORT}`;
const isCI = !!process.env.CI;
/**
* Some sandboxes and prebuilt CI images ship a Chromium that does not match the
* revision `@playwright/test` would download. Point this at that binary rather
* than re-downloading; unset, Playwright resolves its own browser as usual.
*/
const executablePath = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE || undefined;
export default defineConfig({
testDir: './e2e',
globalSetup: './e2e/global-setup.ts',
timeout: 30_000,
expect: { timeout: 10_000 },
fullyParallel: false,
// The specs write real records through the REST API; a single worker keeps
// the assertions on seeded aggregates deterministic.
workers: 1,
forbidOnly: isCI,
// A retry buys the trace below. Locally, failing fast is more useful.
retries: isCI ? 2 : 0,
reporter: isCI
? [['github'], ['list'], ['html', { open: 'never' }]]
: [['list']],
use: {
baseURL: BASE_URL,
headless: true,
// `off` meant a CI failure produced a bare assertion message and nothing to
// debug from. The retry above makes the first failure cheap to re-run with
// a full trace attached.
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'], launchOptions: { executablePath } },
},
],
// `objectstack start` serves the built artifact, so the build has to run
// first. Reusing an already-running dev server locally keeps the edit/run
// loop fast; CI always gets a cold, freshly built server.
webServer: {
command: `pnpm run build && pnpm exec objectstack start -p ${PORT}`,
url: `${BASE_URL}/api/v1/health`,
reuseExistingServer: !isCI,
timeout: 180_000,
stdout: 'pipe',
stderr: 'pipe',
},
});