Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test: jsdom's localStorage on Node 25 and later (#10725)

Cindy Zhang07e325e5337b
diff --git a/vitest.config.ts b/vitest.config.ts
index 91a66573f5..89ea568e4e 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -27,6 +27,13 @@ import DurationShardSequencer from './scripts/vitest-shard-sequencer.mjs';
const rootDir = path.resolve(__dirname, '.');
const coreSrc = path.resolve(__dirname, 'packages/core/src');
+// Some Node 25 releases leave the negative spelling out of this list, so the
+// check reads the positive one.
+const webStorageOff = process.allowedNodeEnvironmentFlags.has(
+ '--experimental-webstorage',
+)
+ ? ['--no-experimental-webstorage']
+ : [];
// Times the Markdown helper pipeline against the empty one on the CPU clock.
// CPU time still includes cache and memory-bandwidth contention from other
// work, so this file runs alone in the `perf` project.
@@ -96,7 +103,9 @@ export default defineConfig({
// Increase worker heap to prevent OOM crashes on memory-heavy test files
// (e.g. Chat composer tests with contentEditable + popover portals in
// jsdom). Vitest 4 removed `poolOptions`; per-worker argv is now top-level.
- execArgv: ['--max-old-space-size=4096'],
+ // Node 25 and later define their own `localStorage` global, which hides
+ // jsdom's; a Node that knows the flag turns its own off in the workers.
+ execArgv: ['--max-old-space-size=4096', ...webStorageOff],
// A `--shard` leg of the `node` project runs files chosen by their
// recorded time, not by count, so the slowest files never share a leg
// (scripts/vitest-shard-sequencer.mjs, spec:AST-030 FR22).