Unverified Commit d31fbae3 authored by Lemon-miaow's avatar Lemon-miaow
Browse files

test(i18n): 语言检测用例每个都从空存储开始,Node 22 下不再读到模块加载时缓存的英文

parent 6b5bd705
Loading
Loading
Loading
Loading
+8 −1
Changes for panel/src/i18n/language.test.ts: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
// @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();
});