私は提案のために反応intlを調べたが、enzymeの明示的な文書は残さない。酵素と反応するintl成分を調べる
これは私がテストを書く方法です。
import {IntlProvider} from 'react-intl';
const intlProvider = new IntlProvider({locale: 'en'}, {});
const intl = intlProvider.getChildContext();
const customMessage = shallow(<CustomMessage />, { options: { context: intl } });
しかし、私は不変違反エラーに
を得続ける:[国際を反応させるのが]必要な
intl
オブジェクトが見つかりませんでした。コンポーネントの祖先に存在する必要があります。
私は彼らのレポを調べました。彼らはmade it workを 'react-addons-test-utils'としているようです。
何か間違っていますか?
これは、「浅い」インスタンス化の良いアプローチです。 Enzymeの 'mount'メソッドを使用している場合、これは機能しません。 – Mirage
enzyme-react-intlパッケージを試しましたか? – JoeTidee