test(traffic): keep the timing test's Vite cache out of the package tree

The traffic timing test starts a Vite server rooted at the package, which
wrote its dependency cache to node_modules/.vite and kept writing after the
server closed. A host running Core's suite then finds files inside Core and
its check refuses them. The server now uses a temporary cache directory,
removed afterwards, and skips dependency discovery, which the SSR-loaded
modules never need.

The HUD place-lookup changelog note credits its PR, #1459.
This commit is contained in:
Sameh Khamis committed 2026-11-01 22:47:05 -08:00
1 parent e8d5e8793e
commit e40bff37d2
2 files changed
+12 -1

No files matched your search

+11
View File
@@ -1,5 +1,8 @@
import assert from 'node:assert/strict';
import { readLayerSource } from '../testSupport/readLayerSource.mjs';
import { mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import test from 'node:test';
import { fileURLToPath } from 'node:url';
@@ -136,6 +139,7 @@ test('traffic timing pairs real ordering to the scheduling change and guards re-
const timeouts = new Map();
let timerId = 0;
let server;
const cacheDir = mkdtempSync(path.join(tmpdir(), 'gev-traffic-timing-vite-'));
let trafficLayer;
let viewer;
@@ -159,6 +163,12 @@ test('traffic timing pairs real ordering to the scheduling change and guards re-
};
server = await createServer({
root: fileURLToPath(new URL('../..', import.meta.url)),
// Its own optimizer cache, not node_modules/.vite in the package tree:
// a host running Core's suite refuses files inside Core.
cacheDir,
// The test loads modules over SSR; the browser dependency optimizer would
// keep writing its cache after the server closes.
optimizeDeps: { noDiscovery: true, include: [] },
configFile: false,
appType: 'custom',
logLevel: 'silent',
@@ -328,6 +338,7 @@ test('traffic timing pairs real ordering to the scheduling change and guards re-
console.warn = originalWarn;
performance.clearMarks();
performance.clearMeasures();
rmSync(cacheDir, { recursive: true, force: true, maxRetries: 3 });
}
});