From dcfb0d2a5fc547a87afbdac5448f5ea2f35d845a Mon Sep 17 00:00:00 2001 From: waterbro-8 Date: Tue, 22 Sep 2026 12:18:02 +0000 Subject: [PATCH] =?UTF-8?q?test:=20=E7=BB=9F=E4=B8=80=E6=B8=85=E7=90=86=20?= =?UTF-8?q?React=20=E6=B5=8B=E8=AF=95=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vitestSetup.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vitestSetup.ts b/vitestSetup.ts index aa9bedb..1c98e44 100644 --- a/vitestSetup.ts +++ b/vitestSetup.ts @@ -1,4 +1,11 @@ -import { vi } from 'vitest' +import { cleanup } from '@testing-library/react' +import { afterEach, vi } from 'vitest' + +// Vitest globals are intentionally disabled, so React Testing Library cannot +// auto-register its own cleanup hook. Unmount every rendered tree before the +// JSDOM environment is torn down; pending React 19 transitions can otherwise +// try to commit against an already-disposed window. +afterEach(cleanup) vi.mock('next/router', () => require('next-router-mock')) vi.mock('@/i18n/routing', () => ({