私は別の「接続されたコンポーネント」(つまりcontainer
)をマウントするコンポーネントSampleComponent
を持っています。私は(私はcomponentDidMount
を必要とするので)INGのmount
でSampleComponent
をテストしようとすると、私はエラーを取得する:React&Reduxの内部での酵素によるネストされたコンポーネントのテスト
Invariant Violation: Could not find "store" in either the context or props of "Connect(ContainerComponent)". Either wrap the root component in a , or explicitly pass "store" as a prop to "Connect(ContainerComponent)".
これをテストする最良の方法は何ですか?私は基本的にやった
mountを使っているのを見て、 '' mount''を '' shallo''に置き換えるとエラーが出ます。あなたもそれに遭遇しましたか? – Mehrdad
この回答は一部のケースでは機能しますが、コンポーネントのライフサイクルをテストする必要がある場合は機能しません。たとえば、 'wrapper.setProps()'を呼び出すと、 'SampleComponent'に' componentWillReceiveProps() 'がトリガーされません。 –