-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
TS error when using vitest globals and @testing-library/jest-dom #517
Comments
Just verified I have the same issue using |
I suggest creating an issue at @testing-library/jest-dom |
Will do. If I find a workaround we can add it to the |
I've come up with a crude workaround that's removed the block for me for now. |
Another workaround testing-library/jest-dom#427 (comment) |
I used this workaround with the |
This comment was marked as outdated.
This comment was marked as outdated.
Do you still recommend this template? |
@adamaslan it should still work. For new projects, I've decided to not use globals and instead go with this approach: https://github.com/typescript-course/react-avatar-tutorial/blob/5173c2881d546b29949e2a5343da2bb7ff2cf7bd/setupTests.ts See full commit for vitest + testing-lib setup: typescript-course/react-avatar-tutorial@5173c28 |
Also found this library: https://github.com/chaance/vitest-dom Not sure how up to date it is! |
That's work for me! |
Also works for me!! |
I think it should be stuck on the top... I dont know how to do that... Maybe there should be a repo like awesome-vite, called "awesome-vitest", and put those nice libs in it...? |
just switched to jest... |
Fixed by testing-library/jest-dom#511 Use this code snippet: import '@testing-library/jest-dom/vitest' |
Describe the bug
I have a
pnpm
monorepo containing a React component library and an app. The component library is usingvitest
,@testing-library/react
and uses@testing-library/jest-dom
to extendexpect
which means I need to use vitest globals.The problem is that
@testing-library/jest-dom
pulls in@types/jest
which causes a clash when typechecking my code prior to building.Any ideas how I can workaround this?
Reproduction
Repo here: https://github.com/robcaldecott/pnpm-vite-monorepo-example
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: