Files
iptvnator/apps/electron-backend-e2e/playwright.xtream-performance.config.ts
T
4grayandClaude Opus 5.5 4ad83d4781 fix(e2e): stop mock servers from outliving Playwright runs
Playwright stops a webServer with a SIGKILL to the process group it
spawned, but `nx run-commands` starts its command in a detached process
group of its own. Launching the Xtream/Stalker mocks through
`pnpm nx run *-mock-server:serve` therefore left the tsx server running
(reparented to PID 1) and holding its port after every run, so the next
run failed with "…/health is already used" or silently reused a stale
server.

Every Playwright config now starts the mocks as a single
`node --import tsx apps/<mock>/src/main.ts` process with
TSX_TSCONFIG_PATH=tsconfig.base.json, which stays in Playwright's group.
A project-config spec guards all playwright*.config.ts files against
regressing to the Nx launch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 23:29:51 +02:00

38 lines
1.1 KiB
TypeScript

import { randomBytes } from 'node:crypto';
import { workspaceRoot } from '@nx/devkit';
import { defineConfig } from '@playwright/test';
const controlToken =
process.env['IPTVNATOR_XTREAM_MOCK_CONTROL_TOKEN'] ??
randomBytes(32).toString('base64url');
process.env['IPTVNATOR_XTREAM_MOCK_CONTROL_TOKEN'] = controlToken;
export default defineConfig({
fullyParallel: false,
reporter: [['list']],
retries: 0,
testDir: './src',
testMatch: 'xtream.performance.ts',
timeout: 30 * 60 * 1_000,
use: {
testIdAttribute: 'data-test-id',
},
webServer: {
// One node process (not `nx run`) so the run's kill reaches it.
command: 'node --import tsx apps/xtream-mock-server/src/main.ts',
cwd: workspaceRoot,
env: {
HOST: '127.0.0.1',
IPTVNATOR_XTREAM_MOCK_CONTROL: '1',
IPTVNATOR_XTREAM_MOCK_CONTROL_TOKEN: controlToken,
NODE_ENV: 'development',
PORT: '3221',
TSX_TSCONFIG_PATH: 'tsconfig.base.json',
},
reuseExistingServer: false,
url: 'http://127.0.0.1:3221/health',
},
workers: 1,
});