Skip to content

Commit ef2677b

Browse files
Omar Essammeta-codesync[bot]
authored andcommitted
Fix Wrong Base URL used
Summary: ## Context * Some nest apps hardcode localhost as part of the base url. * This breaks CI as in ci you are not guaranteed the same port and should use the base url set by the nest_app_provider ## What This Diff Does * Adjusts the faulty configs to use getBaseURL() helper Differential Revision: D107175839 fbshipit-source-id: 9b5771af0bbb8885b377f7e2630af4070e44a9aa
1 parent 0f747a3 commit ef2677b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

playwright.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
// LICENSE file in the root directory of this source tree.
55

66
import { defineConfig, devices } from '@playwright/test';
7+
import {getBaseUrl} from '../../libs/playwright/src';
8+
import * as path from 'path';
9+
10+
const appDir = path.resolve(__dirname);
11+
12+
// getBaseUrl handles all environments:
13+
// 1. PLAYWRIGHT_BASE_URL env var (deployed previews)
14+
// 2. NEST_APP_SERVER env var (CI via Buck's nest_app_resource_provider)
15+
// 3. Local dev server (hostname + port from .next/dev/status.json)
16+
const baseURL = getBaseUrl(appDir);
717

818
export default defineConfig({
919
testDir: 'tests/e2e',
@@ -13,7 +23,7 @@ export default defineConfig({
1323
workers: process.env.CI ? 1 : undefined,
1424
reporter: 'html',
1525
use: {
16-
baseURL: 'http://localhost:3000',
26+
baseURL,
1727
trace: 'on-first-retry',
1828
},
1929
projects: [
@@ -24,7 +34,7 @@ export default defineConfig({
2434
],
2535
webServer: {
2636
command: 'npm run build && npm start',
27-
url: 'http://localhost:3000',
37+
url: baseURL,
2838
reuseExistingServer: !process.env.CI,
2939
},
3040
});

0 commit comments

Comments
 (0)