Skip to content

v6: polyfill localStorage in test setup for Node 24 + jsdom#4334

Merged
trevor-scheer merged 4 commits into
graphiql-6from
trevor/localstorage-polyfill
Jun 6, 2026
Merged

v6: polyfill localStorage in test setup for Node 24 + jsdom#4334
trevor-scheer merged 4 commits into
graphiql-6from
trevor/localstorage-polyfill

Conversation

@trevor-scheer
Copy link
Copy Markdown
Contributor

@trevor-scheer trevor-scheer commented Jun 5, 2026

Node 24 ships with a jsdom version that defines window but leaves localStorage undefined, which causes StorageAPI to throw on construction in unit tests. This adds a minimal in-memory localStorage polyfill to the vitest setup files for @graphiql/react and @graphiql/toolkit, gated on typeof localStorage === 'undefined' so it has no effect in environments where the real API is present. The toolkit package previously had no setup file, so this also wires one into its vitest.config.mts.

Node 24 defines `window` via jsdom but leaves `localStorage` undefined,
causing `StorageAPI` to throw on construction. Add a minimal in-memory
polyfill to `setup-files.ts` in both `@graphiql/react` and
`@graphiql/toolkit` (adding a setup file + vitest config wiring for
the latter).
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 5, 2026

⚠️ No Changeset found

Latest commit: a5c70a6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@trevor-scheer trevor-scheer marked this pull request as ready for review June 6, 2026 02:42
@trevor-scheer trevor-scheer enabled auto-merge (squash) June 6, 2026 02:43
@trevor-scheer trevor-scheer merged commit 8b70057 into graphiql-6 Jun 6, 2026
12 checks passed
@trevor-scheer trevor-scheer deleted the trevor/localstorage-polyfill branch June 6, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant