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