如何在酶中检测input.focus()。我在用反应来写剧本。我的代码如下:
public inputBox: any;
componentDidUpdate = () => {
setTimeout(() => {
this.inputBox.focus();
}, 200);
}
render() {
return (
<div>
<input
type = 'number'
ref = {element => this.inputBox = element } />
</div>
);
}发布于 2019-08-09 12:21:04
可以使用选择器检查特定元素。
const wrapper = mount(<MyComponent />);
const input = wrapper.find('input');
expect(input.is(':focus')).toBe(true);https://stackoverflow.com/questions/37694900
复制相似问题