フロントエンジニア芸人もりたけんじのreact

testでこれが出たら「Invariant Violation: Could not find “store” in either the context or props」

testでこれが出たら「Invariant Violation: Could not find "store" in either the context or props」

React conponentをEnzymeでテストしようとして「Invariant Violation: Could not find "store" in either the context or props」が出たら
下の記事

https://hackernoon.com/unit-testing-redux-connected-components-692fa3c4441c

記事は解決方法は2パターンあるとして
・mockのstoreを作るか
・connectしていないcomponentとしてtestを作るか
としている

一例(recomposeを使っていますが考え方は一緒)
connectに渡す前にexport で外部参照できるようにして、それをtestする。stateなどはtest内で作る