在测试表单时,我使用userEvent在文本框中输入'hello‘,然后使用toHaveValue()直接测试所述文本框的值时,它向后返回字符串...
render(<Form />)
userEvent.clear(screen.getAllByRole('textbox')[0])
userEvent.type(screen.getAllByRole('textbox')[0], 'hello')
expect(screen.getAllByRole('textbox')[0]).toHaveValue('hello')执行纱线测试后控制台出现错误:

包版本:
"react-scripts": "^3.4.3",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.1.9",发布于 2021-09-21 04:50:28
我也经历过同样的事情,我之前使用的是JEST^24.8.0,在升级到最新版本(JEST^27.2.1)后,这个问题得到了解决。
https://stackoverflow.com/questions/68164052
复制相似问题