From 93a8823c3392e6f96c9a1014cd38e7417e85b920 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Tue, 28 Apr 2026 14:25:56 +0200 Subject: [PATCH] svelte: Disable `paths.relative` for Playwright tests SvelteKit 2.58.0 (sveltejs/kit#15718) emits root-layout stylesheets in the server HTML to avoid a flash of unstyled content. With `paths.relative: true` (the default), those hrefs are relative to the request URL. Percy preserves the attribute strings verbatim and renders the snapshot at a different URL, so the relative hrefs no longer resolve and the snapshot comes out unstyled. Force absolute paths under `PLAYWRIGHT=1` to keep Percy snapshots stable. --- svelte/svelte.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/svelte/svelte.config.js b/svelte/svelte.config.js index c00bb630cd3..19f03be87be 100644 --- a/svelte/svelte.config.js +++ b/svelte/svelte.config.js @@ -18,6 +18,10 @@ const config = { // to be able to serve it alongside the Ember.js app at `/`. // Use empty base path for tests (Vitest unit tests and Playwright e2e tests). base: process.env.VITEST || process.env.PLAYWRIGHT ? '' : '/svelte', + // Force absolute asset URLs under Playwright so that Percy's DOM + // serializer captures hrefs that still resolve when the snapshot is + // rendered at a different URL. + ...(process.env.PLAYWRIGHT && { relative: false }), }, prerender: { origin: `https://${process.env.DOMAIN_NAME ?? 'crates.io'}`,