From 8f40655d6482d30babf8b3c64468ea9e64be0d41 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 27 Mar 2026 14:25:14 +0900 Subject: [PATCH] fix: add TextDecoder/TextEncoder to custom VM environment (#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) --- test/core/test/environments/custom-env.test.ts | 5 +++++ test/core/vitest-environment-custom/index.ts | 2 ++ 2 files changed, 7 insertions(+) diff --git a/test/core/test/environments/custom-env.test.ts b/test/core/test/environments/custom-env.test.ts index cd4ba6a9bef3..e0b8a6d3502a 100644 --- a/test/core/test/environments/custom-env.test.ts +++ b/test/core/test/environments/custom-env.test.ts @@ -2,6 +2,11 @@ import { expect, test } from 'vitest' +test('TextDecoder and TextEncoder are available', () => { + expect(typeof TextDecoder).toBe('function') + expect(typeof TextEncoder).toBe('function') +}) + test('custom env is defined', () => { expect(expect.getState().environment).toBe('custom') expect((globalThis as any).testEnvironment).toBe('custom') diff --git a/test/core/vitest-environment-custom/index.ts b/test/core/vitest-environment-custom/index.ts index f03f22f92de4..72694817b8b7 100644 --- a/test/core/vitest-environment-custom/index.ts +++ b/test/core/vitest-environment-custom/index.ts @@ -19,6 +19,8 @@ export default { AbortController, EventTarget, Event, + TextDecoder, + TextEncoder, }) return { getVmContext() {