我基本上试图创建一个静态方法,它将作为我传递的任何方法的包装器,并将在方法本身的实际执行之前和之后执行某些操作.我更喜欢使用Java 8新的编码风格.到目前为止,我有一个具有静态方法的类,但我不确定参数类型应该是什么,因此它可以采用任何类型的参数的任何方法,然后执行它.就像我提到的,我希望在方法执行之前和之后做一些事情.
例如:executeAndProcess(anyMethod(anyParam));
我有一个 react 项目,并且包含了 i18next = 15.0.4 和 react-i18next = 10.2.0 依赖项。我已经创建了一个用于使用 react-i18next 初始化 i18next 的模块,并且我正在尝试使用 Jest 对这段代码进行单元测试。
我尝试导入初始化 i18next 的 i18n 模块并使用 jest 对其进行单元测试。
这是我的 i18n.ts 模块
import i18next from "i18next";
import { initReactI18next } from "react-i18next";
const config = {
resources: {
en: {
static: {},
},
},
fallbackLng: "en",
defaultNS: "static",
ns: "static",
interpolation: {
prefix: "[",
suffix: "]",
},
};
i18next.use(initReactI18next).init(config);
export default i18next;
Run Code Online (Sandbox Code Playgroud)
我试图从我的测试代码中调用它(i18n.test.ts):
import i18n from "./i18n";
describe("i18n", () => {
it("should work fine", () …
Run Code Online (Sandbox Code Playgroud)