I am using Testing Library + i18next, and trying to pass translations into Testing Library's query methods, but am getting type errors. However, it works fine if I declare the result of the translate function as a variable. Maybe this is by design, or something is off with the types in one of those two libraries?
See the CodeSandbox here.
import { screen } from "@testing-library/dom";
import i18n from "i18next";
// This works
const translation = i18n.t("my.translation.string");
screen.getByText(translation);
// This does not:
// Argument of type 'TFunctionResult' is not assignable to parameter of type 'Matcher'.
// Type 'undefined' is not assignable to type 'Matcher'.
screen.getByText(i18n.t("my.translation.string"));