简体   繁体   中英

Property 'getAllByRole' does not exist on type 'Screen'. TS2339

I'm working on a web application in which the front end is built using ReactJs. When I run the code, I'm getting this error as mentioned.

 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");

When I suppress the error with // @ts-ignore , everything is working fine. Please tell me how to get resolve this error.

Make sure that you are using Screen type form @testing-library/react . There is a Screen type in lib.dom.d.ts and it is resolved by tsconfig

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM