Skip to content

Conversation

unikitty37
Copy link

Add instructions on how to configure Vitest to import @testing-library/jest-dom automatically, to match the Vite instructions at 6.2.

Add instructions on how to configure Vitest to import @testing-library/jest-dom automatically, to match the Vite instructions at 6.2.
@netlify
Copy link

netlify bot commented Mar 8, 2023

Deploy Preview for testing-library ready!

Name Link
🔨 Latest commit 0c7931c
🔍 Latest deploy log https://app.netlify.com/sites/testing-library/deploys/6409ddefdc85bc0008a0737f
😎 Deploy Preview https://deploy-preview-1229--testing-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

import '@testing-library/jest-dom';
```

To have Vitest import this automatically in _every_ test file, add the import statement to a new file, then add the file to the `setupFiles` array in the `vitest.config.ts` (in this case, the file is `vitest.include.jsdom.ts` in the project root)
Copy link
Member

@timdeschryver timdeschryver Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this addition to the docs.
What do you think of adding this under a 5.3 bullet point?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a good idea.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you use a library specifically for Jest in Vitest? We already have an assertion library specifically for Vitest called vitest-dom. Could we clarify first if the folks at @testing-library/jest-dom want to support Vitest in addition to Jest?

@unikitty37
Copy link
Author

Why would you use a library specifically for Jest in Vitest? We already have an assertion library specifically for Vitest called vitest-dom. Could we clarify first if the folks at @testing-library/jest-dom want to support Vitest in addition to Jest?

I was just updating the current documentation, which uses jest-dom. I didn't even know about vitest-dom — but it doesn't seem to be compatible with the current vitest version:

╰─▷ npm i -D vitest-dom npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: frontend@0.0.1 npm ERR! Found: vitest@0.25.8 npm ERR! node_modules/vitest npm ERR! dev vitest@"~0.25.3" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer vitest@"^0.16.0" from vitest-dom@0.0.4 npm ERR! node_modules/vitest-dom npm ERR! dev vitest-dom@"*" from the root project 
@unikitty37
Copy link
Author

Since vitest-dom doesn't work with current vitest, and my comment pointing this out doesn't seem to have resulted in any response, I'm going to assume this contribution is unwanted at this point.

@unikitty37 unikitty37 closed this Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants