Files
lincodex/frontend/playwright.config.ts
T

58 lines
2.1 KiB
TypeScript

import { defineConfig, devices } from "@playwright/test";
// deploy/scripts/e2e.sh starts an isolated Compose stand and runs this suite
// in the Playwright image that shares the frontend container's network
// namespace, so the browser reaches the stand at http://localhost:8080.
const baseURL = process.env.E2E_BASE_URL;
if (!baseURL) {
throw new Error("Set E2E_BASE_URL or run the suite with `make -C deploy test-e2e`.");
}
// The suite creates synthetic data as it grows. Refuse any origin other than
// a local stand so a misconfigured run cannot reach a shared environment.
const allowedHosts = new Set(["localhost", "127.0.0.1", "[::1]"]);
if (!allowedHosts.has(new URL(baseURL).hostname)) {
throw new Error(`E2E_BASE_URL must point to a local stand, got ${baseURL}.`);
}
const artifactsDir = process.env.E2E_ARTIFACTS_DIR ?? "test-results/e2e";
// The real-bank search runs first and alone. An unfiltered bank search returns
// the candidates that earlier specs published, so the test is independent of
// the other specs only if it runs before them (see the header of
// match-search.spec.ts).
const realBankSearch = /employer candidate search with the real backend/;
export default defineConfig({
testDir: "./e2e",
outputDir: `${artifactsDir}/results`,
forbidOnly: Boolean(process.env.CI),
// One worker: every browser shares one client address, so all browsers draw
// on one per-address API budget of the stand's Nginx. Two workers left too
// little margin in the busiest seconds of the suite (see docs/en/TESTING.md).
workers: 1,
retries: 0,
reporter: [["list"], ["html", { outputFolder: `${artifactsDir}/report`, open: "never" }]],
use: {
baseURL,
locale: "ru-RU",
trace: "retain-on-failure",
screenshot: "only-on-failure",
video: "off",
},
projects: [
{
name: "real-bank-search",
testMatch: /match-search\.spec\.ts$/,
grep: realBankSearch,
use: { ...devices["Desktop Chrome"] },
},
{
name: "chromium",
dependencies: ["real-bank-search"],
grepInvert: realBankSearch,
use: { ...devices["Desktop Chrome"] },
},
],
});