From d31fbae3cfefc862854e7608ef42ac084d4b3255 Mon Sep 17 00:00:00 2001 From: Lemon-miaow Date: Tue, 29 Sep 2026 02:28:50 +0800 Subject: [PATCH] =?UTF-8?q?test(i18n):=20=E8=AF=AD=E8=A8=80=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E7=94=A8=E4=BE=8B=E6=AF=8F=E4=B8=AA=E9=83=BD=E4=BB=8E?= =?UTF-8?q?=E7=A9=BA=E5=AD=98=E5=82=A8=E5=BC=80=E5=A7=8B=EF=BC=8CNode=2022?= =?UTF-8?q?=20=E4=B8=8B=E4=B8=8D=E5=86=8D=E8=AF=BB=E5=88=B0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=8A=A0=E8=BD=BD=E6=97=B6=E7=BC=93=E5=AD=98=E7=9A=84?= =?UTF-8?q?=E8=8B=B1=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- panel/src/i18n/language.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/panel/src/i18n/language.test.ts b/panel/src/i18n/language.test.ts index a7abf5b..fd04c38 100644 --- a/panel/src/i18n/language.test.ts +++ b/panel/src/i18n/language.test.ts @@ -1,5 +1,5 @@ // @vitest-environment jsdom -import { describe, it, expect, vi, afterEach } from "vitest"; +import { describe, it, expect, vi, afterEach, beforeEach } from "vitest"; import i18next from "i18next"; import LanguageDetector from "i18next-browser-languagedetector"; import { i18nOptions } from "./index"; @@ -15,6 +15,13 @@ async function boot(languages: string[]) { return instance; } +// Importing ./index boots the app's own instance, which on some Node versions (22, +// which CI runs) caches jsdom's en-US in storage before the first test; a first +// visit starts from empty storage, and no test may inherit another's choice. +beforeEach(() => { + localStorage.clear(); +}); + afterEach(() => { vi.restoreAllMocks(); });