52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import { defineConfig, devices } from "@playwright/test";
|
|
|
|
/**
|
|
* E2E for the app shell. The done-criteria is "passes at 360px viewport", so
|
|
* the shell tests pin a mobile viewport. The webServer builds + starts the app
|
|
* against the same Postgres the app uses in production.
|
|
*
|
|
* `DATABASE_URL` is overridable so CI can point at its own Postgres service
|
|
* while local runs keep the development database on :5433.
|
|
*/
|
|
const DATABASE_URL =
|
|
process.env.TEST_DATABASE_URL ??
|
|
process.env.DATABASE_URL ??
|
|
"postgres://media:media@localhost:5433/media";
|
|
|
|
export default defineConfig({
|
|
testDir: "./e2e",
|
|
fullyParallel: true,
|
|
retries: process.env.CI ? 2 : 0,
|
|
// Serial: both suites share one Postgres and reset it in beforeAll. Parallel
|
|
// workers would truncate mid-read (one suite resets while another reads an
|
|
// empty grid), so run one file at a time. The suite is tiny (~2s).
|
|
workers: 1,
|
|
reporter: "list",
|
|
use: {
|
|
baseURL: "http://localhost:3000",
|
|
trace: "on-first-retry",
|
|
},
|
|
projects: [
|
|
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
|
|
],
|
|
webServer: {
|
|
// Playwright sets NODE_ENV=test for the runner. Next 15.5's build hangs
|
|
// when that value is inherited, so unset it before building/serving.
|
|
command:
|
|
"unset NODE_ENV; pnpm db:migrate && pnpm build && PORT=3000 pnpm start",
|
|
url: "http://localhost:3000",
|
|
reuseExistingServer: true,
|
|
env: {
|
|
|
|
DATABASE_URL,
|
|
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET ?? "e2e-secret-for-shell-tests",
|
|
NEXTAUTH_URL: "http://localhost:3000",
|
|
// Tests create users by email and reset the database between suites.
|
|
AUTO_ACTIVATE_NEW_USERS: "true",
|
|
MAGIC_LINK_DEV_TRANSPORT: "true",
|
|
ALLOW_DEV_RESET: "true",
|
|
},
|
|
timeout: 600_000,
|
|
},
|
|
});
|