-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
🐛 Bug Report
The test below passes on 16.1.4 but fails on 16.2.0: The final assertion expects the text to have changed to German, but it is still in English.
To Reproduce
Run the following vitest:
import { act, render, screen } from "@testing-library/react";
import { createInstance } from "i18next";
import { I18nextProvider, useTranslation } from "react-i18next";
import { expect } from "vitest";
it("regression in 16.2.0", async () => {
const i18next = createInstance();
await i18next.init({
fallbackLng: ["en"],
react: { bindI18nStore: "added" },
});
const TranslateAKey = () => {
const { t } = useTranslation();
return <h1>{t("key", { ns: "namespace" })}</h1>;
};
i18next.addResourceBundle("en", "namespace", { key: "english" }, false, true);
render(
<I18nextProvider i18n={i18next}>
<TranslateAKey />
</I18nextProvider>,
);
expect(screen.getByRole("heading")).toHaveTextContent("english");
await act(() => i18next.changeLanguage("de"));
expect(screen.getByRole("heading")).toHaveTextContent("english");
await act(() => i18next.addResourceBundle("de", "namespace", { key: "deutsch" }, false, true));
expect(screen.getByRole("heading")).toHaveTextContent("deutsch"); // this assertion fails
});Expected behavior
The test should pass.
Your Environment
- runtime version: node v22
- i18next version: 25.6.0
- Windows
- Relevant packages:
- "react": "18.3.1"
- "@testing-library/react": "16.3.0"
- "i18next": "25.6.0"
- "react-i18next": "16.2.0"
- "vitest": "3.2.4"
- "jsdom": "27.0.1"
Metadata
Metadata
Assignees
Labels
No labels