From 0a6206e9a8dd11ed29e26e33322f96c9c0879fa2 Mon Sep 17 00:00:00 2001 From: Lydia Vilchez Date: Wed, 12 Aug 2026 10:23:21 +0200 Subject: [PATCH] fix(ui): pre-optimize @peculiar/x509 and reflect-metadata for vitest browser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Azure certificate generator (PROWLER-2378) imports @peculiar/x509 and reflect-metadata. Without them in vitest.config.ts optimizeDeps.include, Vite discovered them the first time a component test loaded the cert generator lazily and emitted "optimized dependencies changed. reloading" mid-run. That reload races with Playwright's route handlers on the integration project, surfacing as "Unhandled Rejection: There was an error when mocking a module" and taking down the whole run in CI. Pre-bundling both packages up front removes the mid-run reload — verified by clearing node_modules/.vite and rerunning the previously-failing providers-page.integration.test.tsx: 62/62 pass with no reload warning. --- ui/vitest.config.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/vitest.config.ts b/ui/vitest.config.ts index dac9e8a762..3acd1e596c 100644 --- a/ui/vitest.config.ts +++ b/ui/vitest.config.ts @@ -106,6 +106,13 @@ export default defineConfig(() => { "vitest-browser-react", "msw/browser", + // Azure certificate generator (PROWLER-2378). Vite would otherwise + // discover these two on first import inside a component test, which + // triggers a mid-run "optimized dependencies changed. reloading" and + // races with Playwright's route handlers. + "@peculiar/x509", + "reflect-metadata", + // React runtime (pre-bundle so a cold run doesn't re-optimize and // reload mid-test — see the on-demand-reload note above). "react-dom/client",