Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/apps/web/playwright.config.ts
blob: 2faad97c3fa422dffb4efaa6f1ffb5da907979d9 (plain)
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
// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later

import { defineConfig } from "@playwright/test";
import { layoutHosts } from "./e2e/pages";

/**
 * Layout tests of the built site in Chromium, at the widths of phones, a
 * tablet and a desktop.
 *
 * The site picks its pages by host name, so every public host name resolves
 * to the local server: the browser asks for http://viget.progmasoft.com/ and
 * the request reaches `next start` on 127.0.0.1 with that Host header. No
 * request leaves the machine.
 */
const port = 3100;
const hostRules = layoutHosts
  .map((host) => `MAP ${host} 127.0.0.1:${port}`)
  .join(", ");

const phone = { isMobile: true, hasTouch: true, deviceScaleFactor: 2 };

export default defineConfig({
  testDir: "e2e",
  fullyParallel: true,
  forbidOnly: Boolean(process.env.CI),
  reporter: process.env.CI
    ? [["list"], ["html", { open: "never", outputFolder: "playwright-report" }]]
    : "list",
  use: {
    browserName: "chromium",
    launchOptions: { args: [`--host-resolver-rules=${hostRules}`] },
    screenshot: "only-on-failure",
    trace: "retain-on-failure",
  },
  projects: [
    {
      name: "phone-360",
      use: { ...phone, viewport: { width: 360, height: 780 } },
    },
    {
      name: "phone-390",
      use: { ...phone, viewport: { width: 390, height: 844 } },
    },
    {
      name: "tablet-768",
      use: { ...phone, viewport: { width: 768, height: 1024 } },
    },
    { name: "desktop-1280", use: { viewport: { width: 1280, height: 800 } } },
  ],
  webServer: {
    command: `pnpm exec next start --hostname 127.0.0.1 --port ${port}`,
    url: `http://127.0.0.1:${port}/robots.txt`,
    reuseExistingServer: !process.env.CI,
    timeout: 120_000,
  },
});