From edde9292e6f44beea78da72a6c7fddca0042e597 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 12 May 2026 22:32:03 +0200 Subject: [PATCH] test(setup): also disable data-sveltekit-preload-code in browser tests Hover-prefetch has two surfaces in SvelteKit: - data-sveltekit-preload-data (route loader data) - data-sveltekit-preload-code (route JS chunks) The original fix turned off only the loader-data side. Route-code chunks prefetched on hover can also include manually-mocked module URLs; an in-flight code prefetch landing after iframe teardown hits the same Playwright route handler that resolves manual mocks, raising the unhandled rejection. Disable both surfaces. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/__meta__/browser-preload-disabled.svelte.test.ts | 6 +++++- frontend/src/test-setup.ts | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/__meta__/browser-preload-disabled.svelte.test.ts b/frontend/src/__meta__/browser-preload-disabled.svelte.test.ts index 60e79b2a..cad43c8e 100644 --- a/frontend/src/__meta__/browser-preload-disabled.svelte.test.ts +++ b/frontend/src/__meta__/browser-preload-disabled.svelte.test.ts @@ -10,7 +10,11 @@ import { describe, it, expect } from 'vitest'; // This test enforces that the test-setup file ran and switched preload-data // off on `document.body` before any spec started rendering. describe('browser test setup', () => { - it('disables SvelteKit hover prefetch on document.body', () => { + it('disables SvelteKit loader-data prefetch on document.body', () => { expect(document.body.dataset.sveltekitPreloadData).toBe('off'); }); + + it('disables SvelteKit route-code prefetch on document.body', () => { + expect(document.body.dataset.sveltekitPreloadCode).toBe('off'); + }); }); diff --git a/frontend/src/test-setup.ts b/frontend/src/test-setup.ts index b7317f9c..efdba26e 100644 --- a/frontend/src/test-setup.ts +++ b/frontend/src/test-setup.ts @@ -1,8 +1,14 @@ -// Disable SvelteKit hover-prefetch in browser-mode tests. ADR-012 / #553. +// Disable SvelteKit hover-prefetch (both data + code) in browser-mode tests. +// ADR-012 / #553. // // Hover-prefetch fires real fetch requests for route loader chunks; those // requests go through the same Playwright route handler that serves mocked // modules. An in-flight prefetch landing after iframe teardown can hit the // route handler with a closed birpc channel, raising an unhandled rejection // that exits the run with code 1 even when every individual test was green. +// +// `data-sveltekit-preload-data="off"` disables loader-data prefetch; +// `data-sveltekit-preload-code="off"` disables route-code chunk prefetch. +// Both surfaces can produce late module fetches that hit the route handler. document.body.dataset.sveltekitPreloadData = 'off'; +document.body.dataset.sveltekitPreloadCode = 'off';