【发布时间】:2021-12-24 17:20:35
【问题描述】:
我需要测试这个场景:
- 在组件中:
t("some.key", { name: "Ash" })
- 在 json 中:
{ "some": { "key": "Hi {{name}}" }
我想监视“t”函数并在测试中获取传递了哪些参数以及返回了什么。
有些是这样的:
expect(spyed).toHaveBeenCaledWith("some.key", { name: "Ash" })
expect(spyed).toHaveReturnedWith("Hi Ash")
【问题讨论】:
标签: reactjs unit-testing jestjs react-testing-library i18next