coo*_*kun 6 javascript reactjs react-testing-library user-event
我正在开发一个 CMS 项目,刚刚遇到一个问题。_userEvent.default.clear is not a function。
import user from \'@testing-library/user-event\'\n\ntest(\'can edit label\', async () => {\n createArticleMock()\n await renderRootAndInitStore(rightNowTeasers, globalInitialState)\n\n const index = 1\n const input = screen.getByDisplayValue(labels[index])\n const newLabel = \'V\xc3\x84RLDEN\'\n user.clear(input)\n user.type(input, newLabel)\n\n expect(await screen.findByDisplayValue(newLabel))\n user.click(screen.getByTestId(\'settings-form-save\'))\n await screen.findByText(newLabel)\n})\nRun Code Online (Sandbox Code Playgroud)\n\n当我访问时@testing-library/user-event,我看到那些线条
// Definitions by: Wu Haotian <https://github.com/whtsky>\nexport interface IUserOptions {\n allAtOnce?: boolean;\n delay?: number;\n}\n\nexport interface ITabUserOptions {\n shift?: boolean;\n focusTrap?: Document | Element;\n}\n\nexport type TargetElement = Element | Window;\n\ndeclare const userEvent: {\n click: (element: TargetElement) => void;\n dblClick: (element: TargetElement) => void;\n selectOptions: (element: TargetElement, values: string | string[]) => void;\n type: (\n element: TargetElement,\n text: string,\n userOpts?: IUserOptions\n ) => Promise<void>;\n tab: (userOpts?: ITabUserOptions) => void;\n};\n\nexport default userEvent;\nRun Code Online (Sandbox Code Playgroud)\n\n正如文件所示clear(),userEvent. 但文档指出了clear()方法。
文档 =>文档
\n\n这是我第一次使用这个库。有人知道问题是什么吗?
\n小智 4
您必须将@testing-library/user-event更新到最新版本。然后该错误将得到解决。您可以在这里找到最新版本: https: //www.npmjs.com/package/@testing-library/user-event
| 归档时间: |
|
| 查看次数: |
11181 次 |
| 最近记录: |