When you using jest 原创内容,盗版必究。【作者:唐霜】to test react applic本文版权归作者所有,未经授权不得转载。【关注微信公众号:wwwtangshuangnet】ation, you may have 【关注微信公众号:wwwtangshuangnet】未经授权,禁止复制转载。doubts about how to 转载请注明出处:www.tangshuang.net原创内容,盗版必究。test components whic【未经授权禁止转载】著作权归作者所有,禁止商业用途转载。h are wrapped by rea本文作者:唐霜,转载请注明出处。本文作者:唐霜,转载请注明出处。ct-i18next’s t转载请注明出处:www.tangshuang.net【作者:唐霜】ranslate function, a【版权所有】唐霜 www.tangshuang.net本文作者:唐霜,转载请注明出处。nd how could you ver【访问 www.tangshuang.net 获取更多精彩内容】本文版权归作者所有,未经授权不得转载。ify the translation 本文版权归作者所有,未经授权不得转载。【版权所有,侵权必究】is applied to your a【本文受版权保护】原创内容,盗版必究。pplication. Now let&本文作者:唐霜,转载请注明出处。【原创不易,请尊重版权】#8217;s talk about t原创内容,盗版必究。【未经授权禁止转载】his topic.
本文作者:唐霜,转载请注明出处。【原创内容,转载请注明出处】【版权所有,侵权必究】本文版权归作者所有,未经授权不得转载。1. testing a transla【版权所有】唐霜 www.tangshuang.net【原创不易,请尊重版权】ted component
转载请注明出处:www.tangshuang.net著作权归作者所有,禁止商业用途转载。【关注微信公众号:wwwtangshuangnet】This is easy, accord转载请注明出处:www.tangshuang.net【原创内容,转载请注明出处】ing to react-i18next【版权所有,侵权必究】未经授权,禁止复制转载。 document here, you have several c【未经授权禁止转载】【原创内容,转载请注明出处】hoices, but the best【关注微信公众号:wwwtangshuangnet】【版权所有】唐霜 www.tangshuang.net one I think is to d原创内容,盗版必究。著作权归作者所有,禁止商业用途转载。o as want you did in转载请注明出处:www.tangshuang.net转载请注明出处:www.tangshuang.net your app.js:
转载请注明出处:www.tangshuang.net著作权归作者所有,禁止商业用途转载。本文作者:唐霜,转载请注明出处。const enzymeWrapper = mount(
<Provider store={store}>
<I18nextProvider i18n={i18n}>
<ContactTable />
</I18nextProvider>
</Provider>
);
You even do not need著作权归作者所有,禁止商业用途转载。【版权所有,侵权必究】 a mock config (like【原创内容,转载请注明出处】本文版权归作者所有,未经授权不得转载。 react-redux), just 原创内容,盗版必究。本文版权归作者所有,未经授权不得转载。do as what you have 【本文首发于唐霜的博客】【版权所有,侵权必究】done in your app.js.
【本文受版权保护】【版权所有】唐霜 www.tangshuang.net【原创内容,转载请注明出处】【关注微信公众号:wwwtangshuangnet】But here you will fa【作者:唐霜】原创内容,盗版必究。cing another problem原创内容,盗版必究。【原创内容,转载请注明出处】 if you use backend 转载请注明出处:www.tangshuang.net本文版权归作者所有,未经授权不得转载。mode in your i18n in【访问 www.tangshuang.net 获取更多精彩内容】本文作者:唐霜,转载请注明出处。itialize file.
【访问 www.tangshuang.net 获取更多精彩内容】未经授权,禁止复制转载。2. verify translated【作者:唐霜】【未经授权禁止转载】 text
著作权归作者所有,禁止商业用途转载。原创内容,盗版必究。You want to know whe【访问 www.tangshuang.net 获取更多精彩内容】本文作者:唐霜,转载请注明出处。ther i18next has tra【本文首发于唐霜的博客】原创内容,盗版必究。nslated your text in【关注微信公众号:wwwtangshuangnet】著作权归作者所有,禁止商业用途转载。 testing, so you do 转载请注明出处:www.tangshuang.net【关注微信公众号:wwwtangshuangnet】what I have told you【作者:唐霜】未经授权,禁止复制转载。 in previous code. B著作权归作者所有,禁止商业用途转载。【未经授权禁止转载】ut if you use backen【原创不易,请尊重版权】原创内容,盗版必究。d mode in your initi【转载请注明来源】【本文受版权保护】alize file, you will著作权归作者所有,禁止商业用途转载。【本文首发于唐霜的博客】 find that your text【版权所有】唐霜 www.tangshuang.net【转载请注明来源】s are not translated【版权所有】唐霜 www.tangshuang.net著作权归作者所有,禁止商业用途转载。, the key in t function will be re本文作者:唐霜,转载请注明出处。转载请注明出处:www.tangshuang.netturn.
The reason is when y转载请注明出处:www.tangshuang.net【未经授权禁止转载】ou use backend mode,著作权归作者所有,禁止商业用途转载。转载请注明出处:www.tangshuang.net jest will not reque【版权所有,侵权必究】【版权所有,侵权必究】st translations file原创内容,盗版必究。【原创内容,转载请注明出处】s from server side (【本文首发于唐霜的博客】【本文受版权保护】there is no server s【关注微信公众号:wwwtangshuangnet】【本文受版权保护】ide in jest testing)【未经授权禁止转载】【本文首发于唐霜的博客】, so the resolution 未经授权,禁止复制转载。【关注微信公众号:wwwtangshuangnet】is to convert backen【转载请注明来源】转载请注明出处:www.tangshuang.netd mode to sync mode.【原创不易,请尊重版权】著作权归作者所有,禁止商业用途转载。 Create a new initia【原创不易,请尊重版权】未经授权,禁止复制转载。lize file for testin原创内容,盗版必究。【未经授权禁止转载】g:
【版权所有】唐霜 www.tangshuang.net转载请注明出处:www.tangshuang.net【关注微信公众号:wwwtangshuangnet】【作者:唐霜】import i18n from "i18next"; import enCommonTranslations from "./locales/en/common.json"; import zhCommonTranslations from "./locales/en/common.json"; i18n .init({ lng: "en", ns: ["common"], defaultNS: "common", resources: { en: { common: enCommonTranslations }, zh: { common: zhCommonTranslations } }, debug: false, interpolation: { escapeValue: false }, react: { wait: false, nsMode: "fallback" } }); export default i18n;
Use this new file as转载请注明出处:www.tangshuang.net转载请注明出处:www.tangshuang.net initialize file in 原创内容,盗版必究。【作者:唐霜】your testing, and yo【本文首发于唐霜的博客】未经授权,禁止复制转载。u will be excited. A【作者:唐霜】【版权所有】唐霜 www.tangshuang.netll languages are per本文版权归作者所有,未经授权不得转载。原创内容,盗版必究。loaded before unit t【原创内容,转载请注明出处】【本文受版权保护】est, and now you can【版权所有】唐霜 www.tangshuang.net未经授权,禁止复制转载。 get translated text【本文受版权保护】本文版权归作者所有,未经授权不得转载。 from your component【关注微信公众号:wwwtangshuangnet】未经授权,禁止复制转载。.
【未经授权禁止转载】著作权归作者所有,禁止商业用途转载。【版权所有,侵权必究】本文版权归作者所有,未经授权不得转载。
