【发布时间】:2019-08-31 21:07:29
【问题描述】:
我正在为我的 react 应用程序使用 react-testing-library。 在一个测试用例中,我需要在文本框中填充一些值并聚焦。
这是测试脚本-
it('searchbox wrapper',async()=>{
let wrapper=getSearchBoxWrapperInstance('')
let inputBox=wrapper.findByTestId('inputText');
inputBox.value='12345';
fireEvent(inputBox,'focusOut');
})
运行测试用例时出现以下错误 -
TypeError: element.dispatchEvent is not a function
79 | let inputBox=wrapper.findByTestId('inputText');
80 | inputBox.value='12345';
> 81 | fireEvent(inputBox,'focusOut');
| ^
82 | //fireEvent('Blur',
83 |
84 | //await (() => wrapper.getByText('')))
at fireEvent (node_modules/dom-testing-library/dist/events.js:533:18)
如果我可以提供更多信息,请告诉我
【问题讨论】:
标签: reactjs react-testing-library