Skip to content

test: add TextDecoder/TextEncoder to custom environment example to fix Vite 8#9989

Merged
sheremet-va merged 1 commit intovitest-dev:mainfrom
hi-ogawa:fix/9987-textdecoder-vm-custom-env
Mar 27, 2026
Merged

test: add TextDecoder/TextEncoder to custom environment example to fix Vite 8#9989
sheremet-va merged 1 commit intovitest-dev:mainfrom
hi-ogawa:fix/9987-textdecoder-vm-custom-env

Conversation

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa commented Mar 27, 2026

Description

Vite 8 now access TextDecoder in module runner vitejs/vite#21985 and it breaks custom vm environment test case. For now, this just fixes on custom environment example side. Our builtin environment (node, jsdom, etc) fills globals including TextDecoder, so this is only custom environment issue. Not sure if this (Vite 8 change) should be taken as breaking change or not. Probably we can wait. Otherwise, maybe need to fill more context around here

context.setImmediate = setImmediate
context.clearImmediate = clearImmediate

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

…#9987)

The custom test environment's setupVM() was missing TextDecoder and
TextEncoder globals. This caused a ReferenceError with Vite 8, which
now uses TextDecoder at the top level of its module-runner.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hi-ogawa hi-ogawa marked this pull request as ready for review March 27, 2026 05:30
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8f40655
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69c615b72a16bd00084ec6cd
😎 Deploy Preview https://deploy-preview-9989--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hi-ogawa hi-ogawa changed the title test: add TextDecoder/TextEncoder to custom VM environment (#9987) test: add TextDecoder/TextEncoder to custom environment example Mar 27, 2026
@hi-ogawa hi-ogawa changed the title test: add TextDecoder/TextEncoder to custom environment example test: add TextDecoder/TextEncoder to custom environment example to fix Vite 8 Mar 27, 2026
@sheremet-va sheremet-va merged commit 6c44a12 into vitest-dev:main Mar 27, 2026
12 of 16 checks passed
@hi-ogawa hi-ogawa deleted the fix/9987-textdecoder-vm-custom-env branch March 27, 2026 07:07
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.

Vite 8 CI fails with ReferenceError: TextDecoder is not defined

2 participants