Javascript 测试react导航组件时出错

Javascript 测试react导航组件时出错,javascript,reactjs,react-native,jestjs,react-navigation,Javascript,Reactjs,React Native,Jestjs,React Navigation,我已经创建了一个组件,它正在使用react redux中的Provider和NavigationContainer中的react navigation,但在测试时抛出了错误 import React from 'react'; import { Provider } from 'react-redux'; import { NavigationContainer } from 'react-navigation'; import { createGlobalStore } from 'from

我已经创建了一个组件,它正在使用
react redux
中的
Provider
NavigationContainer
中的
react navigation
,但在测试时抛出了错误

import React from 'react';
import { Provider } from 'react-redux';
import { NavigationContainer } from 'react-navigation';
import { createGlobalStore } from 'from somewhere';
import RootComponent from './RootComponent';

const middlewaresToApply = [];
const globalStore = createGlobalStore(middlewaresToApply);

class EntryComponent extends React.Component {
    render() {
        return (
            <Provider store={globalStore}>
                <NavigationContainer>
                    <RootComponent />
                </NavigationContainer>
            </Provider>
        );
    }
}

export default EntryComponent;

你的错误是什么?@BloodyMonkey添加了错误日志,似乎你没有设置屏幕。导航用于在屏幕之间导航,但您没有。检查是否未为导航添加doc yes屏幕。但是你的意思是说如果不设置,我的测试用例将失败吗?我测试过,它似乎可以工作。为什么要这样创建EntryComponent?真奇怪。您的错误看起来像EntryComponent没有返回任何内容。你能发布代码吗?你有什么错误?@BloodyMonkey添加了错误日志。看起来你没有设置屏幕。导航用于在屏幕之间导航,但您没有。检查是否未为导航添加doc yes屏幕。但是你的意思是说如果不设置,我的测试用例将失败吗?我测试过,它似乎可以工作。为什么要这样创建EntryComponent?真奇怪。您的错误看起来像EntryComponent没有返回任何内容。你能把密码寄出去吗?
import React from 'react';
import renderer from 'react-test-renderer';
import EntryComponent from '../EntryComponent';

describe('Does EntryComponent render correctly', () => {
    it('When tested using snapshot.', () => {
        const tree = renderer.create(<EntryComponent />).toJSON();
        expect(tree).toMatchSnapshot();
    });
});
  Check your code at EntryComponent.js:18.
      in EntryComponent (at EntryComponent.test.js:10)
console.error node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9036
  The above error occurred in the <Context.Provider> component:
      in Provider (at EntryComponent.js:17)
      in EntryComponent (at EntryComponent.test.js:10)
  
  Consider adding an error boundary to your tree to customize error handling behavior.