[英]Property 'getAllByRole' does not exist on type 'Screen'. TS2339
我正在開發一個 web 應用程序,其中的前端是使用 ReactJs 構建的。當我運行代碼時,出現了上述錯誤。
TypeScript error in My_project/src/unitTestUtils.tsx(79,27):
Property 'getAllByRole' does not exist on type 'Screen'. TS2339
> 79 | const rowGroups = scope.getAllByRole("rowgroup");
當我使用// @ts-ignore
抑制錯誤時,一切正常。 請告訴我如何解決此錯誤。
確保您使用的是Screen
類型表單@testing-library/react
。 lib.dom.d.ts
中有一個Screen
類型,由tsconfig
解析
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.