@testing-library/react version: 10.0.0react version: 16.13.0node version: 12.13.0npm (or yarn) version: 1.21.1import { waitFor } from '@testing-library/react';
I get a typescript error:
@types/testing-library__react"' has no exported member 'waitFor'.ts(2305)
I have @testing-library/react@^10.0.0 and @types/testing-library__react@^9.1.3 installed. I believe each is the latest version.
My current workaround is to add // @ts-nocheck to get my test with waitFor() to pass.
This will be fixed as soon as this is merged: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43102 馃榿
@kentcdodds it might be better to close issues once they are actually resolved. Open issues have a better visibility for others encountering the same problem
You're not wrong, but I like to only keep issues open for as long as they have action items we can take within the project where they are. It helps keep things organized.
I'm still getting this issue using @testing-library/[email protected]
Me too. @kentcdodds Could you please reopen this issue?
We have to bump our dependency on @types/testing-library__react once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43108 is merged. Re-opening since this requires action in this repository.
@eps1lon Did you mean to re-open this?
--Edit: Nevermind, I needed to restart my typescript server with latest packages.
i still having the same errors
@roychoo, Hi, after I update @types/testing-libary__react to version 10.0.1, I still got the same error. Inside @types/testing-libary__react folder, the package.json file always reference to the @types/testing-libary__dom@* (the newest one). However, as I read my yarn.lock I saw @types/testing-libary__dom@* always point to the older version (6.0.1 for exp). So I think you may have this problem also. I think you need to modify your yarn.lock file.
The solution I used was yarn add @types/[email protected]. This somehow fixed my issue.
If not you can remove your node modules and re-install or maybe remove yarn.lock.
Sr for my bad English.
@huylocit14054 Installing the types yourself is not an ideal solution IMO while @testing-library/dom already includes these as a dependency, there's a potential for them to get out of sync and cause weird errors. This is very much related to https://github.com/testing-library/react-testing-library/issues/620 and https://github.com/testing-library/dom-testing-library/issues/494
@huylocit14054 Installing the types yourself is not an ideal solution IMO while @testing-library/dom already includes these as a dependency, there's a potential for them to get out of sync and cause weird errors. This is very much related to #620 and testing-library/dom-testing-library#494
@tom-sherman, you are totally correct. So as far as I understand, in my yarn.lock file, the version of @types/testing-library__dom@* is not the newest one as it should be. So I need to do something to update it to the newest version. After fixing my yarn.lock, I can remove @types/testing-library__dom without any problem. Thank you 馃憤.
Fixed with yarn remove @testing-library/react @testing-library/jest-dom && yarn add @testing-library/react @testing-library/jest-dom
Fixed with npm uninstall @testing-library/react @testing-library/jest-dom && npm install --save-dev @testing-library/react @testing-library/jest-dom
"@testing-library/react": "10.0.5",
"@testing-library/jest-dom": "5.9.0",
"react": "16.13.1",
I still get the same error. I've tried all solutions mentioned in this issue, and none helps.
@matassp what version of @testing-library/dom is in your yarn.lock or package-lock.json?
Fixed with
yarn remove @testing-library/react @testing-library/jest-dom && yarn add @testing-library/react @testing-library/jest-dom
...node_modules/@types/testing-library__react"' has no exported member 'screen'
I went from:
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
to:
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^10.4.9",
For the sake of completion I created my app with CRA from npx and I got the following React version:
v16.13.1
Which apparently does not include the proper version of those dependencies to use screen from testing-library/react.
node_modules/@testing-library/dom/node_modules/pretty-format/build/index.d.ts(7,13):
'=' expected. TS1005
5 | * LICENSE file in the root directory of this source tree.
6 | */
> 7 | import type * as PrettyFormat from './types';
| ^
8 | /**
9 | * Returns a presentation string of your `val` object
10 | * @param val any potential JavaScript object
So I am rolling back...
Make sure you're using at least TypeScript 3.8, it's required for import type.
Make sure you're using at least TypeScript 3.8, it's required for
import type.
As I said when building my app I run npx CRA with the typescript template flag... (npx should give me the latest stable, right?)
And it landed with a package.json with:
"typescript": "~3.7.2"
I prefer to rollback and not touch too much what CRA gave me, so I am just descructuring the output of render.
What's the exact version of TypeScript you have installed?
~ means the latest patch, so it would never reach 3.8.x
^ meas latest minor or patch version, so if I had the caret symbol it could potentially install the 3.8.x
Anyway my version is 3.7.5
You'll need something like ^3.7.2 or ~3.8.0. to install at least TypeScript 3.8
I know... and as I already SAID I used npx CRA with the ts template...
I am not going to upgrade @testing-library/react @testing-library/jest-dom and typescript.
All the dependencies should be fine out of the box.
So I will manage without screen.
Thanks!
@gugol2 I have exactly the same issues.
@gugol2 I have exactly the same issues.
Well, I took that approach at that time.
I don't know if running CRA with npx keeps locking the dependencies just the same today, it's been some time...
Sorry I just checked, last release of CRA is 3.4.1 (2020-03-20)
So I guess it must be the same with a fresh project.
I don't find it that painful to just destructure the output of render.
For new react projects still happening. With last versions of everything.
I believe CRA 4 will fix this
still getting this issue
CRA 4 hasn't been released yet. Update your version of @testing-library/react
CRA 4 hasn't been released yet. Update your version of
@testing-library/react
@kentcdodds it is not only about RTL, it complains about other dependencies too...
https://github.com/testing-library/react-testing-library/issues/610#issuecomment-678761385
I tried but in the end I rolled back, IMHO it is not so much pain to just destructure the output of render.
Now CRA 4 is here!!!
https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md#400-2020-10-23
"To infinity.... and Beyond"
Most helpful comment
Fixed with
yarn remove @testing-library/react @testing-library/jest-dom && yarn add @testing-library/react @testing-library/jest-dom