我正在用酶浅。我想获取传递给测试文件中组件的道具。就像在示例中一样,但是我变得不确定。
<property>
<name>dfs.namenode.kerberos.principal</name>
<value>hdfs/_HOST@CORP</value>
</property>
应该返回props的对象,但是它返回一些jsx对象。
请协助我获取要为其编写测试用例的某些组件的道具。
这是我的代码:
console.log(wrapper.props())
答案 0 :(得分:1)
const wrapper = mount(<MyComponent foo={10} />);
expect(wrapper.props().children).to.equal(10);
编辑:
就像@Must keem指出的那样,这也可以:
const wrapper = mount(<MyComponent foo={10} />);
expect(wrapper.instance().props.foo).to.equal(10);