【发布时间】:2017-02-16 15:19:57
【问题描述】:
我正在尝试使用 Enzyme 测试自定义 Material-ui React 组件,但出现以下错误:
ERROR: 'Warning: Failed context type: Required context 'muiTheme' was not specified in 'ChildComponent'.
我尝试的是根据this 设置上下文。我要访问和测试的组件是子组件。
const root = shallow(<RootComponent />, {context: {muiTheme}, childContextTypes: {muiTheme: React.PropTypes.object}})
const child = root.find(ChildComponent)
child.render() // <--- this line is throwing the error
【问题讨论】:
标签: javascript unit-testing reactjs enzyme