ShallowWrapper只能包装有效元素-酶Reactjs

时间:2018-11-30 16:26:20

标签: javascript reactjs mocha enzyme chai

我正在为组件编写测试以测试其功能之一,但出现错误: curl -d "test=true" -X POST 'https://outlook.office.com/webhook/09f2b8e5-e684-4e87-8838-75e3a2f9dcbc@00d35244-2e42-4af7-a1ad-d6b557249c2b/58f4ab6b-234c-43ad-82f0-4641e38699e0/c516d999fec5498e9cac06f8d0478f22/79e349e1-47da-487a-90ee-040eccbbfa8b' Unknown Connector provider 58f4ab6b-234c-43ad-82f0-4641e38699e0

组件文件如下-ShallowWrapper can only wrap valid elements(简体):

Panel.jsx

测试文件如下- class Panel extends Component { static propTypes = { ... }; static defaultProps = { ... }; constructor(props) { super(props); ... this.makeConfigArray = this.makeConfigArray.bind(this); this.filterSelected = this.filterSelected.bind(this); } makeConfigArray() { ... } filterSelected(filters) { ... } render() { return ( <div> <ReactFilterSentence filters={this.makeConfigArray()} label="Filter Page" isPersistent onChange={(...args) => this.filterSelected(args)} /> <span className="page-filter__config-form-separator" /> </div> ); } } export default Panel;

panel-test.jsx

任何想法,为什么会发生这种情况,将不胜感激!

1 个答案:

答案 0 :(得分:0)

const getPanelWrapper = () => shallow(<Panel {...props}/>);

应为:

const getPanelWrapper = shallow(<Panel {...props}/>);