-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"types": ["jest", "@testing-library/jest-dom"]
not working after v6 upgrade
#559
Comments
This reverts #9673 and #9711. With v6 of `@testing-library/jest-dom`, `yarn rw type-check` fails in Redwood projects because it can't locate the types for `@testing-libary/jest-dom`. They absorbed the definitely types package (`@types/testing-library__jest-dom`) in this PR: testing-library/jest-dom#511. Here's an example of a failing run: https://github.com/redwoodjs/redwood/actions/runs/7213177056/job/19668365614?pr=9708. The logical thing to do is remove `@testing-libary/jest-dom` from the `types` array in `web/tsconfig.json`, but when we do that we get a different failure from TS saying that it doesn't understand the extended matchers provided by `testing-library/jest-dom` like `toBeInTheDocument`. @Tobbe filed an issue in their repo here testing-library/jest-dom#559. In the PR I linked to, the maintainer notes that... > But in my local testing with the changes in this PR, following the Readme was sufficient to get full auto-complete support even for JS-only users. As long as they have a jest-setup file that imports the bare export and add a dependency on @types/jest, recent versions of VS Code will figure it out. Users don't have jest setup files in their project (we just point to a jest preset) or `@types/jest` as an explicit dev dependency. I took a look at it but couldn't crack it today. Instead of holding up other PRs in CI, better to revert it for now and come back to later when we have more leads.
Figured out how to configure it! and as text for easier searching "typeRoots": ["../node_modules/@types", "./node_modules/@types", "../node_modules/@testing-library"],
"types": ["jest-dom"], Because I'm not sure if this should be classified as a regression. Or if some docs should be updated. |
@Tobbe's answer was helpful. Thanks. |
@testing-library/jest-dom
version: 6.1.5node
version: 18.19.0jest
(orvitest
) version: jest 29.7.0npm
(oryarn
) version: yarn 3.7.0Relevant code or config:
part of tsconfig
And package.json
Also tried with adding
"@types/jest": "^29.5.11"
, but no differenceWhat you did:
We upgraded from v5.17.0 to v6.1.5
What happened:
Get the following error
Reproduction:
Problem description:
Or CI is failing, blocking more PRs getting merged.
Suggested solution:
Not a solution really, but more of a workaround.
Update
tsconfig
to remove"@testing-library/jest-dom"
Now I get
But if I now go into the test file and add
Then all works.
But we didn't have to do that before, so why do we need to now?
The text was updated successfully, but these errors were encountered: