Skip to content

Commit 6592798

Browse files
committed
Fix flaky E2E tests - added a devServerPort constant in astro.config.ts (defaults to DEV_SERVER_PORT or 4321) and wired it into vite.server.hmr.clientPort so Vite instructs the browser to negotiate HMR websockets through the same externally exposed port Astro serves on
1 parent 7194df0 commit 6592798

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎astro.config.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import { privacyPolicyVersion } from './src/integrations/PrivacyPolicyVersion'
3535
import { pwaDevAssetServer } from './src/lib/plugins/pwaDevAssetServer'
3636
import { createSerializeFunction, pagesJsonWriter } from './src/integrations/sitemapSerialize'
3737

38+
// Ensure Vite's HMR websocket connects through the same exposed dev server port used by Astro.
39+
const devServerPort = Number(process.env['DEV_SERVER_PORT'] ?? 4321)
40+
3841
const sharedTestIntegrations = [
3942
icon(),
4043
]
@@ -93,6 +96,11 @@ export default defineConfig({
9396
site: getSiteUrl(),
9497
trailingSlash: 'never',
9598
vite: {
99+
server: {
100+
hmr: {
101+
clientPort: devServerPort,
102+
},
103+
},
96104
build: {
97105
/** Source map generation must be turned on for Sentry. */
98106
sourcemap: true,

0 commit comments

Comments
 (0)