1
所以我想在使用還原形式和酶的同時爲我的組件寫一個測試。 到目前爲止,我簡單的組件我創建了下面的函數使用通用函數測試酶的還原形式
export const mountWithContext = (node, store) => {
const nodeToMount = store ? <Provider store={store} >{node}</Provider> : node;
return mount(nodeToMount);
};
的問題是,當我試圖使用反應,終極版,以及它失敗。 試圖做的事:
class Form extends Component {
render() {
return <div><TestComponent /></div>
}
}
const TestForm = reduxForm({ form: 'testForm' })(Form);
const enzymeWrapper = mountWithContext(TestForm, store)
而且我發現了以下錯誤
'Warning: Failed prop type: Invalid prop `children` of type `function` supplied to `Provider`, expected a single ReactElement.
Invariant Violation: React.Children.only expected to receive a single React element child.
任何想法,爲什麼出現這種情況,如何解決這個問題?