Reactjs Jest快照测试失败,因为将ShallowRapper添加到快照

Reactjs Jest快照测试失败,因为将ShallowRapper添加到快照,reactjs,redux,jestjs,enzyme,Reactjs,Redux,Jestjs,Enzyme,使用此文件进行测试,并使用Ezyme进行浅层渲染: import React from "react"; import { shallow } from "enzyme"; import { Provider } from "react-redux"; import useStore from "redux-mock-store"; import Dashboard from "./Dashboard"; import { initUserState } from "../../reducer

使用此文件进行测试,并使用Ezyme进行浅层渲染:

import React from "react";
import { shallow } from "enzyme";
import { Provider } from "react-redux";
import useStore from "redux-mock-store";

import Dashboard from "./Dashboard";
import { initUserState } from "../../reducers/user";
import { initProjectsState } from "../../reducers/projects";
import { initPagesState } from "../../reducers/pages";
import thunk from "redux-thunk";

describe('Dashboard', () => {

    const middlewares = [ thunk ];

    const setStore = useStore(middlewares);

    const store = setStore({
        user: initUserState,
        projects: initProjectsState,
        pages: initPagesState
    });

    it('should render correctly', () => {
        const Component = shallow(
            <Provider store={store}>
                <Dashboard />
            </Provider>
        );

        expect(Component).toMatchSnapshot();
    });
});
从“React”导入React;
从“酶”中导入{shall};
从“react redux”导入{Provider};
从“redux模拟存储”导入useStore;
从“/Dashboard”导入仪表板;
从“../../reducers/user”导入{initUserState};
从“../../reducers/projects”导入{initprojectssstate}”;
从“./../reducers/pages”导入{initPagesState}”;
从“redux thunk”导入thunk;
描述('仪表板',()=>{
const middleware=[thunk];
const setStore=useStore(中间件);
常数存储=设置存储({
用户:initUserState,
项目:initProjectsState,
页面:initPagesState
});
它('应该正确呈现',()=>{
常数分量=浅(
);
expect(Component.toMatchSnapshot();
});
});
将此错误返回到终端:

  ● Dashboard › should render correc
tly

    expect(received).toMatchSnapshot
()

    Snapshot name: `Dashboard should
 render correctly 1`

    - Snapshot
    + Received

    - <ContextProvider
    -   value={
    -     Object {
    -       "store": Object {
    -         "clearActions": [Function],
    -         "dispatch": [Function],
    -         "getActions": [Function],
    -         "getState": [Function],
    -         "replaceReducer": [Function],
    -         "subscribe": [Function],
    -       },
    -       "subscription": Subscription {
    -         "handleChangeWrapper": [Function],
    -         "listeners": Object {
    -           "notify": [Function],
    -         },
    -         "onStateChange": [Function],
    -         "parentSub": undefined,
    -         "store": Object {
    -           "clearActions": [Function],
    -           "dispatch": [Function],
    -           "getActions": [Function],
    -           "getState": [Function],
    -           "replaceReducer": [Function],
    -           "subscribe": [Function],
    -         },
    -         "unsubscribe": null,
    -       },
    -     }
    -   }
    - >
    -   <Dashboard />
    - </ContextProvider>
    + ShallowWrapper {}
● 仪表板›应正确显示
泰利
预期(已收到)。toMatchSnapshot
()
快照名称:`仪表板应
正确渲染1`
-快照
+收到
- 
-   
- 
+浅层振打器{}
我不确定它是否符合预期,但它没有通过测试,所以它不应该是正确的。我尝试了
enzyme.mount
,也尝试了
enzyme.shallow
,但两者都返回相同的包装错误。也许是因为redux
提供程序
,但我在很多地方看到了使用这种方法

我做错了什么,如何修复