上下文提供者的模拟状态This.Context.State

时间:2019-07-31 09:50:28

标签: reactjs unit-testing jestjs react-context react-testing-library

我有一个Context provider类Context Consumer,我正在为Context Consumer编写单元测试, 如何在玩笑中模拟Context类的状态

<operatorsContext.Consumer>
    {allState => (
        <React.Fragment>
            {this.context.state.showLoading && (
                <Loading width='100px' height='100px' />
            )};

         </React.Fragment>
    )}
</operatorsContext.Consumer>

0 个答案:

没有答案