我目前正在为我正在处理的项目运行一些测试,并且无法将fireEvent.select()
其用作专注于输入字段的方式。
到目前为止我的测试:
it('is not working :(', () => {
const input = queryByPlaceholderText('blah');
fireEvent.change(input, {
target: {value: 'some text'},
});
expect(input).toHaveAttribute('value', 'some text');
fireEvent.select(input); <-- issue here
});
我正在测试的组件有一个下拉菜单,仅在输入关注时才会显示,但似乎既不关注fireEvent.change()
也不fireEvent.select()
关注该字段。我知道这fireEvent.change()
会改变输入值。
到目前为止,我已经尝试过:
fireEvent.click()
fireEvent.focus()
fireEvent.select()
input.focus()
但这些选项都没有奏效。
我需要能够在此下拉菜单中选择一个选项才能正确测试组件。
TL;博士
有没有办法专注于 RTL 的输入字段?