fix(jsdom): override globals that Fetch API relies on#8390
Merged
sheremet-va merged 2 commits intovitest-dev:mainfrom Aug 6, 2025
Merged
fix(jsdom): override globals that Fetch API relies on#8390sheremet-va merged 2 commits intovitest-dev:mainfrom
sheremet-va merged 2 commits intovitest-dev:mainfrom
Conversation
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
hi-ogawa
previously approved these changes
Aug 6, 2025
matej-pavlik
added a commit
to matej-pavlik/school-vavjs
that referenced
this pull request
Aug 7, 2025
The error originates from Vitest when used with jsdom. See vitest-dev/vitest#7906 for more details. This issue is fixed in vitest-dev/vitest#8390, but not yet released.
|
Sorry to bump this @sheremet-va. Is there any way we could get this added into the next release? Seems like it's currently slotted for the v4 release. Not sure the timeline on when v4 will be released, so this may not be important enough. |
Member
Author
You can use Vitest 4 beta to test this. |
6 tasks
4 tasks
|
pnpm patch for anyone that might want to manually apply this change to
|
6 tasks
5 tasks
This was referenced Nov 3, 2025
1 task
1 task
gr2m
added a commit
to vercel/ai
that referenced
this pull request
Mar 12, 2026
- Fix elevenlabs transcription test snapshot for Node 24 File serialization - Allow Node 24 test matrix to fail until jsdom/vitest compat is resolved Node 24 introduces a stricter AbortSignal instanceof check in native fetch that rejects jsdom's AbortSignal. This is fixed in vitest 3.2.4+ (vitest-dev/vitest#8390) but requires a vitest major version upgrade. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
louise-davies
added a commit
to ral-facilities/scigateway
that referenced
this pull request
Mar 13, 2026
- see vitest-dev/vitest#8390 (comment) for path details - I was running node 22 locally hence I didn't see this issues until CI ran
gr2m
added a commit
to vercel/ai
that referenced
this pull request
Mar 16, 2026
## Summary Adds Node.js 24 to the CI test matrix and fixes all build/test incompatibilities. Closes #13357 ## Changes ### CI & config - Adds Node.js 24 to `.github/workflows/ci.yml` test matrix - Adds `^24.0.0` to root `package.json` engines field ### SvelteKit example build fix - Updates `@sveltejs/adapter-vercel` from v5 to v6 and `@sveltejs/kit` to v2.55+ in `examples/sveltekit-openai` — adapter-vercel v5 only supported Node 18/20/22, v6 adds Node 24 ### Vitest v2 → v4 upgrade Node 24 ships with undici v7, which enforces strict `AbortSignal` instanceof checks in `fetch()`. The jsdom environment in vitest v2/v3 replaces the global `AbortController`/`AbortSignal` with its own polyfill, and Node 24's native fetch rejects these with `"Expected signal to be an instance of AbortSignal"`. Vitest v4 stops overriding these globals ([vitest-dev/vitest#8390](vitest-dev/vitest#8390)), fixing the incompatibility. #### Test adaptations required by vitest v4 **`vi.fn()` arrow functions can no longer be used as constructors** — vitest v4 wraps mock functions differently, so arrow-function mocks fail with `TypeError: is not a constructor` when called with `new`. Fixed by changing arrow functions to `function` expressions in mock implementations: - `packages/amazon-bedrock/src/bedrock-event-stream-response-handler.test.ts` - `packages/baseten/src/baseten-provider.unit.test.ts` - `packages/gateway/src/gateway-provider.test.ts` - `packages/google-vertex/src/google-vertex-auth-google-auth-library.test.ts` **`toStrictEqual(expect.objectContaining(...))` is stricter** — vitest v4 now requires that `undefined` properties on the actual object (e.g. `metadata: undefined`) also appear in the expected pattern. Since these tests intentionally do partial matching, changed to `toEqual(expect.objectContaining(...))`: - `packages/angular/src/lib/chat.ng.test.ts` - `packages/svelte/src/chat.svelte.test.ts` **`toThrowError` with an Error object checks all properties** — previously only checked `message`, now checks every property. The anthropic overloaded-error test compared `requestBodyValues: {}` against the full request body. Changed to try/catch with individual property assertions: - `packages/anthropic/src/anthropic-messages-language-model.test.ts` **`test.workspace` renamed to `test.projects`**: - `packages/svelte/vite.config.ts` ### Other test fixes - `packages/openai` and `packages/elevenlabs`: Made `File` object snapshot tests Node version-agnostic (Node 24 serializes additional `Symbol(state)` on File objects) - `packages/mcp`: Fixed race condition in SSE reconnect test where `server.calls[2]` was accessed before the fire-and-forget `openInboundSse()` completed — added `vi.waitFor()` - Pinned `tinyexec` to 1.0.2 via pnpm overrides (1.0.3 has broken package exports on npm) ### Backports - v6: #13440 - v5: #13441 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #8374
Fixes #7906
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.