Update files

This commit is contained in:
Mohamed Boudra
2026-01-23 15:10:36 +07:00
parent a6869d55c1
commit 0852f4e6d0
7 changed files with 79 additions and 12 deletions
+18 -1
View File
@@ -1,9 +1,21 @@
import { test, expect, type Page } from '@playwright/test';
import { test as base, expect, type Page } from '@playwright/test';
// Extend base test to provide dynamic baseURL from global-setup
const test = base.extend({
baseURL: async ({}, use) => {
const metroPort = process.env.E2E_METRO_PORT;
if (!metroPort) {
throw new Error('E2E_METRO_PORT not set - globalSetup must run first');
}
await use(`http://localhost:${metroPort}`);
},
});
const consoleEntries = new WeakMap<Page, string[]>();
test.beforeEach(async ({ page }) => {
const daemonPort = process.env.E2E_DAEMON_PORT;
const metroPort = process.env.E2E_METRO_PORT;
if (!daemonPort) {
throw new Error(
'E2E_DAEMON_PORT is not set. Refusing to run e2e against the default daemon (e.g. localhost:6767). ' +
@@ -16,6 +28,11 @@ test.beforeEach(async ({ page }) => {
'Fix Playwright globalSetup to start an isolated test daemon and export its port.'
);
}
if (!metroPort) {
throw new Error(
'E2E_METRO_PORT is not set. Ensure Playwright `globalSetup` starts Metro and exports E2E_METRO_PORT.'
);
}
// Hard guardrail: never allow tests to hit the developer's default daemon.
// This blocks both HTTP and WS attempts to :6767 (before any navigation).