JestJS -> Invariant Violation: Could not find “store” in either the context or props of “Connect(Portfolio)”

后端 未结 2 755
小蘑菇
小蘑菇 2021-01-12 03:20

The full error message:

Invariant Violation: Could not find \"store\" in either the context or props of \"Connect(Portfolio)\". Either wrap the root

2条回答
  •  情歌与酒
    2021-01-12 04:06

    Per the error message, you need to make sure that tests for a connected component can actually access a store instance. So, in your test code, you should also use , or . Or, you can export your plain Portfolio component separately, and test that, not the connected version.

    See the Redux docs on testing for more info, as well as the articles on Redux testing approaches in my React/Redux links list.

提交回复
热议问题