酶:简单 .to.have 不起作用
Enzyme: simple .to.have not working
从文档来看,这样的事情应该是可能的:
const wrapper = mount(<Foo name="foo" />);
expect(wrapper.find('.foo')).to.have.length(1);
但在我的例子中,这引发了一个错误,说无法读取 属性 have of undefined.
虽然使用这个有效:
expect(wrapper.find('.foo').length).toBe(1);
您的 expect
函数可能是 expect-enzyme,它具有驼峰式方法 (toBe()
),.to.have
是点分隔的 expect
表示法,如这些文档中所示:
与预期酶
https://github.com/PsychoLlama/expect-enzyme
所以你的 "version" 的 expect 有一个不同的 API,仅此而已。
从文档来看,这样的事情应该是可能的:
const wrapper = mount(<Foo name="foo" />);
expect(wrapper.find('.foo')).to.have.length(1);
但在我的例子中,这引发了一个错误,说无法读取 属性 have of undefined.
虽然使用这个有效:
expect(wrapper.find('.foo').length).toBe(1);
您的 expect
函数可能是 expect-enzyme,它具有驼峰式方法 (toBe()
),.to.have
是点分隔的 expect
表示法,如这些文档中所示:
与预期酶
https://github.com/PsychoLlama/expect-enzyme
所以你的 "version" 的 expect 有一个不同的 API,仅此而已。