fix(ui): pre-optimize @peculiar/x509 and reflect-metadata for vitest browser

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.
This commit is contained in:
Lydia Vilchez committed 2026-08-12 10:23:21 +02:00
1 parent 47c42bbe42
commit 0a6206e9a8
1 file changed
+7
+7
View File
@@ -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",