Either wrap the root component in a , or explicitly pass “store” as a prop to "Connect(CharacterList)

前端 未结 2 695
不知归路
不知归路 2021-02-19 13:13

I am trying to test my React \"supersquadapp\" and getting the following error.

Uncaught Error: Could not find \"store\" in either the context or props of \"Connect(Char

2条回答
  •  长情又很酷
    2021-02-19 13:49

    If you are running a test and you have something like alechill's answer, you'd need this to change in the test, for example:

    let mockedStore = configureStore([])({});
    test('some test', () => {
      const wrapper = mount(, {
        context: { store: mockedStore },
        childContextTypes: { store: PropTypes.object.isRequired }
      });
      expect(.... your tests here);
    });
    

提交回复
热议问题